c# - Generating zip files in azure blob container --getting corrupted -
here trying zip contents of azure blob directory using dotnetzip
here code use this. zip files getting created corrupted. in blob container 'myfiles' ,i want create zip file named "mymusic.zip" reading files , folders within mymusic folder while retaining same folder structure inside zip file. following code creates zip file, zip file getting corrupted .any suggestions resolve ?
string ofurl = @"http://myxyzstorage.blob.core.windows.net/myfiles/mymusic"; string ofblob = @"http://myxyzstorage.blob.core.windows.net/myfiles"; dblob = new cloudblob(blobclient.getblobreference(ofblob)); using (var zipfile = new zipfile()) { byte[] filebytes = dblob.downloadbytearray(); using (var filestream = new memorystream(filebytes)) { filestream.seek(0, seekorigin.begin); zipfile.addentry("myzipfiles"+".zip", filebytes); } var sas = ofcontainer.getsharedaccesssignature(new sharedaccesspolicy() { permissions = sharedaccesspermissions.write, // sharedaccessexpirytime = datetime.utcnow.addseconds(this.timeoutseconds) }); using (var zipstream = new memorystream()) { zipfile.save(zipstream); zipstream.seek(0, seekorigin.begin); var blobref = ofcontainer.getblobreference(ofurl); blobref.uploadfromstream(zipstream); } }
here code above ,i can see generated zip file myzipfile.zip inside blob(http://myxyzstorage.blob.core.windows.net/myfiles/mymusic).but when download , try unzip ,its showing error message "the compressed zipped folder "myzipfiles.zip" invalid .why zip file getting corrupted? how prevent zip file getting corrupted
Comments
Post a Comment