title: Upload Picture to Windows Azure Web Site
body: <p>I have an ASP.NET MVC 4 app that i want to deploy to Windows Azure. A part of this app involves uploading a picture. When the picture is uploaded, I want to store the picture in a directory located at <code>/pictures/uploaded</code>.</p>
  
  <p>My question is, how do I upload a picture to a relative path within my app hosted on Windows Azure? Up to this point, my app has been hosted in a Virtual Machine. I was able to do the above by using the following:</p>
  
  <pre><code>string path = ConfigurationManager.AppSettings["rootWebDirectory"] + "/pictures/uploaded;
  
  // Get the file path
  if (Directory.Exists(path) == false)
    Directory.CreateDirectory(path);
  
  string filePath = path + "/uploaded" + DateTime.UtcNow.Milliseconds + ".png";
  filePath = filePath.Replace("/", "\\").Replace("\\\\", "\\");
  
  // Write the picture to the file system
  byte[] bytes = GetPictureBytes();
  using (FileStream fileStream = new FileStream(filePath, FileMode.Create))
  {
    fileStream.Write(bytes, 0, bytes.Length);
    fileStream.Flush();
    fileStream.Close();
  }
  </code></pre>
  
  <p>Currently, <code>ConfigurationManager.AppSettings["rootWebDirectory"]</code> points to an absolute path. I belive this is where my problem lies. I can't figure out how to switch all of this to a relative path.</p>
  
  <p>Thank you!</p>