vendredi 19 août 2016

Save an image captured from web app to a nas

I am trying to save an image from a web app (c# MVC 4 ) to a NAS. Currently I have it setup like so :

//create a path
string imagePath = globals.PATH_TO_NAS + "/" + date + "/" + box + "/";
try
{
   System.IO.Directory.CreateDirectory(Server.MapPath("."+ imagePath));


   string fileNameWitPath = Path.Combine(Server.MapPath("." + imagePath), fileName);

   using (FileStream fs = new FileStream(fileNameWitPath, FileMode.Create))
     {
       using (BinaryWriter bw = new BinaryWriter(fs))
        {
          byte[] data = Convert.FromBase64String(imageData);
          bw.Write(data);
          bw.Close();
        }
       fs.Close();
      }
}
catch (Exception ex)
 {
  string message = ex.ToString();
 }

My PATH_TO_NAS is defined as such:

public static string PATH_TO_NAS = "\\\\06img.DomainName.local\\Public";

The problem is when I test it it wants to write to my local computer in the project folder, or in the deployed applications local folder (depending if I am testing it "live" or on my machine.

I need it to write to my nas, as my "live" site does not have enough room to store all the image data this application will accrue.




Aucun commentaire:

Enregistrer un commentaire