DotNetZip如何添加选定的文件,而无需创建文件夹 [英] DotNetZip How Add Selected Files without creating folders
本文介绍了DotNetZip如何添加选定的文件,而无需创建文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在压缩文件中添加测试
从路径中的所有PDF文件
使用(VAR邮编=新的ZipFile())
{
zip.AddSelectedFiles(* PDF,路径);
zip.Save(路径+/ test.zip);
}
在创建test.zip文件有此目录:
** ** test.zip \\用户\\管理员\\文档\\ Visual Studio 2010 \\ PROJECTS \\我的项目\\ ** PDF文件**
如何使所有的PDF文档直接在test.zip
test.zip \\ PDF文件
解决方案
请尝试以下方法,
使用(的ZipFile邮编=新的ZipFile())
{
字符串[] =文件Directory.GetFiles(路径);
//过滤文件的* .pdf
zip.AddFiles(文件,测试); //测试文件夹
zip.Save(路径+/ test.zip);
}
I want to add in zip file "test"
all pdf files from path
using (var zip = new ZipFile())
{
zip.AddSelectedFiles("*.pdf",path);
zip.Save(path+"/test.zip");
}
when test.zip file is created have this directory :
**test.zip**\Users\administrator\Documents\vs2010\Projects\my project\**pdf files**
How to make all pdf documents to be directly in test.zip
test.zip\pdf files
解决方案
Please try the following,
using (ZipFile zip = new ZipFile())
{
string[] files = Directory.GetFiles(path);
// filter the files for *.pdf
zip.AddFiles(files, "Test"); //Test Folder
zip.Save(path+"/test.zip");
}
这篇关于DotNetZip如何添加选定的文件,而无需创建文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文