dsb dsb - 1 year ago 120
ASP.NET (C#) Question

Server.MapPath does not find the path on Azure

I have deployed my project to Azure. In my project I have "App_Data\Images" folder.

Now I'm trying to do the following:

String filename = GLOBAL_IMAGES_VALS.GET_FILE_PREFIX(imageType) + "-" + User.Identity.GetUserId<int>().ToString() + Path.GetExtension(image.FileName);

String origPath = Server.MapPath("~\\App_Data")+"\\Images\\" + filename;

But then upon trying:


I get this error message:

Could not find a part of the path

How can I save my file to "App_Data\Images\"?

dsb dsb
Answer Source

The actual problem was that the sub-folder 'Images' did not exist. I can't remember why the publish process did not create this sub-folder, however I added it manually and then everything worked fine.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download