Access Azure App_Data Window

I need to write a file to the App_Data folder in an Asp.Net MVC project. It works locally, but when I deployed it to Windows Azure, I got an error, for example:

  Could not find a part of the path 'C: \ DWASFiles \ Sites \ codehint \ VirtualDirectory0 \ site \ wwwroot \ App_Data \ text.txt'. 

I need to use a third-party library that needs read / write access to the App_Data folder.

I am using code like this:

var path = Server.MapPath("~/App_Data/text.txt"); using (var file = new StreamWriter(path)) { file.Write("test line"); file.Flush(); } 
+6
source share
3 answers

If the App_Data folder is empty, it has not been expanded, so you need to create it

see my answer here

+8
source

I had the same problem and solved it by creating the source file in my App_Data folder and then adding the file to the solution by right-clicking on App_Start and choosing Add-> Existing Item ..

enter image description here

It must be added to the publishing solution.

0
source

If you use VS2017 and right-click on the App_Data folder, you can publish the folder.

0
source

All Articles