c# ZipFile.CreateFromDirectory - the process cannot access the file “path_to_the_zip_file_created.zip” because it is being used by another process

前端 未结 5 1380
礼貌的吻别
礼貌的吻别 2020-12-03 04:22

Basic Code:

string startPath = @\"C:\\intel\\logs\";
string zipPath = @\"C:\\intel\\logs-\" + DateTime.Now.ToString(\"         


        
5条回答
  •  时光说笑
    2020-12-03 05:04

    //WRONG
    ZipFile.CreateFromDirectory("C:\somefolder", "C:\somefolder\somefile.zip");
    //RIGHT     
    ZipFile.CreateFromDirectory("C:\somefolder", "C:\someotherfolder\somefile.zip");
    

    I use to do the same error: zipping a file into the same folder that I'm zipping.
    This causes an error, of course.

提交回复
热议问题