开发者

Extracting and copying files to local folder from a zip archive stored in a blob storage

I have stored my zip file in blob storage . I already read archive from blob to stream .Code is as follows

string blobUrl = http://127.开发者_运维问答0.0.1:10000/devstoreaccount1/usercontrols/ucProfileViewSMSIS.zip";
string containerName = "usercontrols";
Storage.Blob blobHandler = new Storage.Blob();
Stream blobstream = blobHandler.GetBlob(blobUrl, containerName);

I have three files in my archive . I want to write write those 3 files to my local folder .

How do I do this ?


You will need an unzip library like DotNetZip to unzip the files. Under the examples section, there is a method to unzip directly from a stream:

Input from a stream. This example reads in zip archive content from an input stream, then extracts the content for one entry to a filesysten file. In this example, the filename "NameOfEntryInArchive.doc", refers only to the name of the entry within the zip archive. This name is used as the index in the string indexer on the ZipFile object. The return value is a ZipEntry. The ZipEntry.Extract() method is then called, which extracts the named entry to a filesystem file, using the current working directory as the base. A file by that name is created in the filesystem.

using (ZipFile zip = ZipFile.Read(InputStream))
  {
    ZipEntry entry = zip["NameOfEntryInArchive.doc"];
    entry.Extract();  // create filesystem file here. 
  }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜