我想打包一些文件夹使用SharpZipLib压缩。示例结构
directory1:
directory2:
file1
file2
directory3:
directory4:当我在这里使用c#代码将其打包时:
http://wiki.sharpdevelop.net/SharpZipLib-Zip-Samples.ashx#Create_a_Zip_with_full_control_over_contents_0
在没有directory3和directory4的情况下,我可以得到压缩文件。
我的问题是,如何使用directory3和directory4打包以获取归档文件。
发布于 2012-02-16 08:56:09
FastZip fastZip = new FastZip();
fastZip.CreateEmptyDirectories = true;
// Include all files by recursing through the directory structure
bool recurse = true;
// Dont filter any files at all
string filter = null;
fastZip.CreateZip("fileName.zip", @"C:\SourceDirectory", recurse, filter);需要注意的是,它不能处理UTF-8文件名。
以下是指向文档维基的链接:
http://wiki.sharpdevelop.net/SharpZipLib_FastZip.ashx
发布于 2012-10-10 22:33:25
您可以让程序将文件夹添加为条目。
在每个文件夹的循环中添加以下代码。
//Here we create a path for a new entry,
//but this time with the '\' in the end, its a folder
string sEntry = sFolder.Substring(iFolderOffset) + "\\";
sEntry = ZipEntry.CleanName(sEntry);
ZipEntry zeOutput = new ZipEntry(sEntry);
zsOutput.PutNextEntry(zeOutput);
zsOutput.CloseEntry();我还没测试解压呢。
https://stackoverflow.com/questions/9303919
复制相似问题