Add files to ZIP without paths, using SharpZipLib

回眸只為那壹抹淺笑 提交于 2019-12-04 23:36:11

Based on the FAQ, you have to strip the folder path out manually:

How can I create a Zip file without folders?

Remove the path portion of the filename used to create a ZipEntry before it is added to a ZipOutputStream

ZipEntry entry = new ZipEntry(Path.GetFileName(fullPath));

The FAQ can be found here.

It seems to be a limitation of the library. Hope this helps!

If you have your files in a FileSystemInfo, you can use: z.Add(file.FullName, Path.GetFileName(file.FullName));

This will add your files in the root directory of your zip.

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