Zip a folder having subfolders using zipstorer class

你离开我真会死。 提交于 2019-12-12 01:55:24

问题


I am using ZIpstorer class library to compress files. I am able to zip a file by calling zip.AddFile procedure. But I want to zip folders which has subfolders too. So the resulting zip file should have folder and subfolder structure inside the zip file normally. I am not able to do it. if i process each file by looping all folders and sub folders and then if call zip.Addfile then it will result in zip file with all the files inside it without a directory structure.

So how can i zip a folder using Zipstorer class . What changes i have to do?


回答1:


You can use (back)slashes for the _filenameInZip (sic) parameter to add files in a directory in the zip:

zip.Addfile(,,"directory/filename.txt",);

Or

zip.Addfile(,,"directory\\filename.txt",);


来源:https://stackoverflow.com/questions/28231171/zip-a-folder-having-subfolders-using-zipstorer-class

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