none
uploading MemoryStream to Azure Storage Blob, Blob is empty.

    Question

  • I am trying to upload a Memory Stream where stream writer writes lines to the stream, then later on I will download the stream from the blob and save it as a Text file. The problem is that the storage blob is empty and the text file returns empty.

                     var ms = new MemoryStream();
                    using (StreamWriter w = new StreamWriter(ms, Encoding.UTF8))
                    {
                      ms.Position = 0;
                      w.write("Test Text");
    
    
    
                    ConnectAzureStorage();
    
                    var _blobname = DateTime.UtcNow.ToString("HHmmssMMddyyy");
                            var _container = Branch;
                                                 container = blobClient.GetContainerReference(_container.ToLower());
    
                                                   blockBlob = container.GetBlockBlobReference(_blobname);
                            ms.Position = 0;
                                                   
                            blockBlob.UploadFromStream(ms);
    
    
                 
    
    
    		W.close
                   }


    Rogelio Rios


    Thursday, March 17, 2016 6:39 AM

All replies