ASP.NET file loading does not work in windows azure

I wrote some codes to upload a file in an ASP.NET MVC3 project. Instead of storing the file in the database, I downloaded the files in the file system and saved the paths in the database.

The download codes are as follows: -

if (file != null && file.ContentLength > 0)
{
    if (path == null)
    {
        throw new ArgumentNullException("path cannot be null");
    }
    string pFileName = PrefixFName(file.FileName);
    String relpath = String.Format("{0}/{1}", path, pFileName);
    try
    {
        file.SaveAs(Server.MapPath(relpath));
        return pFileName;
    }
    catch (HttpException e)
    {
        throw new ApplicationException("Cannot save uploaded file", e);
    }
}

After saving the file, I used this image with the image tag in several views. My codes work great locally. But when I posted the site at windowsazure.com, everything worked, but the file was uploaded.

How can I get rid of this situation? Please, help.

+3
source share
2 answers

, , , - , , , . , , .

   var path= Server.MapPath("~/ImagesDirectory");

   if (!System.IO.Directory.Exists(path))
   {
       System.IO.Directory.CreateDirectory(path);
   }

, try/catch, NTFS . , , path , , , .

, VS, , . , , "_doNotDelete.txt", . .

+7

- . Azure , () , ()

, . , B , B. , . (, , ). , A, B, .

, blobs, - . http://www.windowsazure.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs-20/

(, ) Server.MapPath("~/App_Data/...")

+3

All Articles