DotNetZip How Add Selected Files without creating folders

限于喜欢 提交于 2019-12-23 05:16:02

问题


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

回答1:


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"); 
  }


来源:https://stackoverflow.com/questions/12596003/dotnetzip-how-add-selected-files-without-creating-folders

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!