Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Azure access App_Data

Tags:

c#

asp.net

azure

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();
}
like image 704
Vasiliy Mazhekin Avatar asked Jan 17 '14 08:01

Vasiliy Mazhekin


2 Answers

If App_Data folder was empty, it was not deployed, so you need to create it

see my reply here

like image 129
Toolkit Avatar answered Oct 21 '22 17:10

Toolkit


If you are using VS2017 and right click on the App_Data folder there is an option to Publish folder.

like image 27
SzymonK Avatar answered Oct 21 '22 18:10

SzymonK