如何使用C#在Azure Blob存储中解压缩大小为40 GB的文件

时间:2018-11-12 21:29:12

标签: c# azure unzip azure-blob-storage

如何使用C#在Azure blob存储中解压缩大小为40 GB的文件?我尝试使用Sharpziplib和ionic.zip。但是我遇到了错误

  

状态错误(无效的块类型)

。有人可以帮我吗?

下面是我的代码

        var storageAccount1 = CloudStorageAccount.Parse(connectionString1);
        var blobClient = storageAccount1.CreateCloudBlobClient();
        CloudBlobContainer container = blobClient.GetContainerReference("testwwpoc");

        if (share.Exists())
        {
            Console.WriteLine("Yes");
            Console.WriteLine("Yes");
            CloudFileDirectory rootDir = share.GetRootDirectoryReference();
            var file = container.GetBlobReference("WAV_WW_5988.zip");

            // Ensure that the file exists.
            if (file.Exists())
            {
                    using (ZipFile zipFile = ZipFile.Read(file.OpenRead()))
                    {

                        zipFile.CompressionLevel = Ionic.Zlib.CompressionLevel.Default;
                        //zipFile.UseZip64WhenSaving = Zip64Option.Always;
                        zipFile.Encryption = EncryptionAlgorithm.None;
                        //zipFile.BufferSize = 65536 * 19000;
                        zipFile.Password = "xyz";

                        Console.WriteLine(zipFile.Entries.Count);
                        //var entry = zipFile.Entries.First();
                        //CloudFileDirectory sampleDir = rootDir.GetDirectoryReference("WAV_WW_5988");

                        //foreach (var entry in zipFile.Entries)
                        for (var i = 1; i < zipFile.Count; i++)
                        {

                            var blob = container.GetBlockBlobReference("test/" + zipFile[i].FileName);//+ entry.FileName);
                            Console.WriteLine(zipFile[i].FileName);
                            Console.WriteLine(zipFile[i].UncompressedSize);


                            try
                            {
                                blob.UploadFromStream(zipFile[i].OpenReader());
                            }
                            catch(Exception ex)
                            {
                                Console.WriteLine(ex);
                            }

                        }
  }

0 个答案:

没有答案