我正在考虑这可能是一个错误。我的方法创建一个zip文件,似乎正确地写入文件和文件夹。一旦我通过catch块,它就会遇到FileNotFound异常,并且在检查.zip时,它会以下列格式附加文件:
[filename].zip.zip
我有什么问题吗?
private void compressDirectory()
{
zipPath = backupPath + @"\" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm") + ".zip";
//At this point, zipPath has the value "c:\testfacility\tree\<date+time>"
//which definitively exists.
try
{
ZipFile.CreateFromDirectory(sourcePath, zipPath, CompressionLevel.Optimal, true);
getresultmessage(); //this line is never hit
}
catch (IOException v)
{
errMsg = "Failed trying to start compression. \n" + v.ToString();
}
}