1

I am using below Powershell command to read CSV file from directory:

$importData = Import-CSV "C:\Projects\news_sample.csv"

It's working fine on my local Sitecore instance and machine. I am running the same script on Azure CM instance and it's not working and throwing the error Directory not found.

Can anyone please let me know, how can I get the server path, I have put the CSV files on the Server using Filezilla but not able to determine the server path? Is there any Powershell command the same as Server.MapPath("~path") in C#?

Thanks.

1 Answer 1

4

In PowerShell you can use the Sitecore.IO.FileUtil.MapPath method to get your path:

$folder = [Sitecore.IO.FileUtil]::MapPath("~/path")
$importData = Import-CSV "$($folder)/news_sample.csv"
1
  • 1
    Thank you so much @Richard, it's solved my issue. Commented Nov 12, 2020 at 4:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.