Basic代码:C#ZipFile.CreateFromDirectory - 该进程无法访问文件“path_to_the_zip_file_created.zip”,因为它正被另一个进程使用
string startPath = @"C:\intel\logs";
string zipPath = @"C:\intel\logs-" + DateTime.Now.ToString("yyyy_dd_M-HH_mm_ss") + ".zip";
ZipFile.CreateFromDirectory(startPath, zipPath);
Error: the process cannot access the file "path_to_the_zip_file_created.zip" because it is being used by another process.
上面的设置工作正常的Windows 7,我安装了Visual Studio,但在Windows Server 2008R2上运行时遇到以上错误消息。
我检查了防病毒日志,它不会阻止应用程序,也不会锁定创建的zip文件。
你有没有想过这个问题? –
这正是我正在发生的事情。 –
压缩文件试图压缩文件夹的所有内容,但仍在读取该文件夹时被写入。这导致它尝试压缩自身。下面的答案表明您不能将压缩文件存储在要压缩的文件夹中。 –