我試圖將文件夾目錄打包到一個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