好吧,我一直在压缩文件,并意识到我错过了基本目录,我只是在添加includeBaseDirectory选项之前压缩内容,现在我给了我错误,请协助,我还是c#
private static void zipFile(string source, string destination)
{
DirectoryInfo di = new DirectoryInfo(source);
DirectoryInfo[] directories = di.GetDirectories();
foreach (DirectoryInfo directory in directories)
{
string from = source + directory;
string to = System.IO.Path.Combine(destination, (directory + ".zip"));
ZipFile.CreateFromDirectory(from, to, CompressionLevel.Fastest, bool includeBaseDirectory, true);
}
}
错误:无效的术语表达,如果我删除单词bool,则说当前上下文中不存在名称'includeBaseDirectory'
答案 0 :(得分:0)
您必须提供方法includeBaseDirectory
所期望的布尔值CreateFromDirectory
的值(在您的情况下为true
):
ZipFile.CreateFromDirectory(from, to, CompressionLevel.Fastest, true);