How to get local file system path in azure websites

后端 未结 5 643
闹比i
闹比i 2020-12-31 20:25

I have a file hosted on the disk along with my website that I want to read .Not sure how do I access the file when I use System.Environment.CurrentDirectory it point to a D

5条回答
  •  生来不讨喜
    2020-12-31 20:46

    This works for me in both localhost and azure:

    Path.Combine(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath, "file_at_root.txt");
    

    System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath is the full local path to your site's root.

提交回复
热议问题