简体   繁体   中英

Zipping files in parts in C#

I am looking for some example which can help me to understand how can i zip files in C# in parts ie if i have 20MB zip archive, I want to split the archive in 4 parts of 5MB each.

I have gone through Stack overflow question and then i even looked at DotNetZip library's documentation but i couldn't find any such example.

Could someone suggest? thanks,

What i am looking for that when i have those 4 files, I can extract them to the original files. So each individual part may not be a proper zip but all 4 parts should extract properly

Do you mean split the ZIP file into multiple files after it has been zipped, meaning you have to re-combine both parts to have a valid ZIP?

You can accomplish this with 7Zip. Here are instructions for doing it with their UI. They also provide an API to automate the task.

http://www.linglom.com/2008/10/12/how-to-split-a-large-file-using-7-zip/

You could also just read the file as binary data, then write it to separate files using your own convention eg my.zip.part1of3, my.zip.part2of3, my.zip.part3of3, etc. When ready, recombine the parts and unzip. If you do this, the person re-assembling the parts would need a custom utility from you.

You can try ICSharpCode to zip the files. Once the file is zip you can use FileStream to save the file in small chunks. I had done this in one of my project. If you require any help, let me know.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM