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

//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.

Leave a Comment