将文件夹压缩为多个zip文件
亲爱的所有人,
i我正在寻找一些可以帮助我理解如何在C#中压缩文件的例子,即如果我有文件夹大小= 20MB,我想压缩它将存档拆分为4个部分,每个5MB。当我有这4个文件时,我可以将它们提取到原始文件中。因此,每个单独的部分可能不是一个合适的拉链,但所有4个部分应该正确提取
有人建议吗?谢谢,
Dear All,
i am looking for some example which can help me to understand how can i zip files in C# in parts i.e. if i have Folder Size = 20MB , I want to Compress It As split the archive in 4 parts of 5MB each. 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
Could someone suggest? thanks,
using (var memoryStream = new MemoryStream())
{
using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true))
{
var demoFile = archive.CreateEntry("foo.txt");
}
using (var fileStream = new FileStream(@"C:\Temp\test.zip", FileMode.Create))
{
memoryStream.Position=0;
memoryStream.WriteTo(fileStream);
}
}
Iam使用System.IO.Compression和一段时间Foo.txt超过3千兆所以我需要分割这个文件到多个压缩文件
谢谢
Iam Using System.IO.Compression and some time Foo.txt Is More than 3 Giga so i need to split this file to multiple compressed file
Thanks
看看这里:System.IO.Packaging命名空间 [ ^ ],提供支持在单个容器中存储多个数据对象的类。
用法: System.IO.Packaging简介 [ ^ ]
另一种选择:
DotNetZip是一个用于操作zip文件的快速免费类库和工具集 [ ^ ]
用法:从ASP.NET应用程序创建ZIP文件 [ ^ ]
Have a look here: System.IO.Packaging Namespace[^], which provides classes that support storage of multiple data objects in a single container.
Usage: Introducing System.IO.Packaging[^]
Another option:
DotNetZip is a FAST, FREE class library and toolset for manipulating zip files[^]
Usage: Create ZIP Files From An ASP.NET Application[^]