我试图将文件夹目录打包到一个zip目录,不包括所有的子文件夹。专用子文件夹的zip目录
目前我使用这种方法打包整个目录。
public void directoryPacker(DirectoryInfo directoryInfo)
{
string pathToRootDirectory = Path.Combine(directoryInfo.Parent.FullName,
directoryInfo.Name) + ".abc"; //name of root file
using(ZipContainer zip = new ZipContainer(pass))
//ZipContainer inherits from Ionic.Zip.ZipFile
{
//some password stuff here
//
//zipping
zip.AddDirectory(directoryInfo.FullName, "/"); //add complete subdirectory to *.abc archive (zip archive)
File.Delete(pathToRootDirectory);
zip.Save(pathToRootDirecotry); //save in rootname.bdd
}
}
这个真正伟大的作品,但现在我有一个
List<string> paths
的路径,我想在我的zipArchive的childfolders内
。其他childfolders(不在列表中)不应该在归档
谢谢
为什么不简单地在你的路径上创建一个foreach循环并为每个路径调用'directoryPacker()'? – RononDex
,因为我在directoryPacker()中做了其他的事情,并且不需要这个子文件夹...只对于根目录 – patdhlk
你是否有单独的子文件夹和rootfolders函数呢? – RononDex