title: upload file to Blob through Windows Forms c#
body: <p>I am working on application that is connected to a Blob Database and I am having an exception being thrown whenever I try to pick a file from my PC and upload it. This is the code:     </p>
  
  <pre><code>StorageCredentials storageCredentials = new StorageCredentials("filep2pstorage", connectionString);
  CloudStorageAccount sotrageAccount = new CloudStorageAccount(storageCredentials, false);
  CloudBlobClient _client = sotrageAccount.CreateCloudBlobClient();
  CloudBlobContainer container = _client.GetContainerReference("filep2pshare");
  container.CreateIfNotExists();
  
  OpenFileDialog dialog = new OpenFileDialog();
  
  dialog.Filter = "Text Files (.txt)|*.txt|All Files (*.*)|*.*";
  dialog.FilterIndex = 1;
  dialog.Multiselect = true;
  
  string filename = dialog.FileName;                 
  string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
  
  dialog.InitialDirectory = path;
  DialogResult result = dialog.ShowDialog();
  
  if (result == DialogResult.OK)
  {
      CloudBlockBlob blob = container.GetBlockBlobReference(filename);
  
      using (var fileStream = File.OpenRead(path + filename))
      {
          blob.UploadFromStream(fileStream);
      }
  }
  </code></pre>
  
  <p>Basically, this line of code here: </p>
  
  <pre><code> CloudBlockBlob blob = container.GetBlockBlobReference(filename);
  
   using (var fileStream = File.OpenRead(path + filename))
   {
        blob.UploadFromStream(fileStream);
   }
  </code></pre>
  
  <p>Does not take the file name. I was breakpointing and the filename is just set to "". </p>