I need to write file to App_Data folder in Asp.Net MVC project. It works locally, but when I deployed it to Windows Azure I received error like:
Could not find a part of the path 'C:\DWASFiles\Sites\codehint\VirtualDirectory0\site\wwwroot\App_Data\text.txt'.
I need to use third party library that have to get read/write access to App_Data folder.
I use code like this:
var path = Server.MapPath("~/App_Data/text.txt");
using (var file = new StreamWriter(path))
{
file.Write("test line");
file.Flush();
}
If App_Data folder was empty, it was not deployed, so you need to create it
see my reply here
If you are using VS2017 and right click on the App_Data folder there is an option to Publish folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With