The process cannot access the file because it is being used by another process error occurs when extracting a zip file

Jan 29, 2015 at 3:20 PM
Edited Jan 29, 2015 at 3:23 PM
Hello

When I try to extract a zip file into the web content folder, I am getting this error.
Skin file extraction failed - Ionic.Zip.ZipException: Cannot extract ---> System.IO.IOException: The process cannot access the file '\machinename\sharedfolderName\foldername\Skins\' because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.Directory.OpenHandle(String path) at System.IO.Directory.SetLastWriteTimeUtc(String path, DateTime lastWriteTimeUtc) at Ionic.Zip.ZipEntry._SetTimes(String fileOrDirectory, Boolean isFile) at Ionic.Zip.ZipEntry.ValidateOutput(String basedir, Stream outstream, String& OutputFile) at Ionic.Zip.ZipEntry.InternalExtract(String baseDir, Stream outstream, String password)
--- End of inner exception stack trace --- at Ionic.Zip.ZipEntry.InternalExtract(String baseDir, Stream outstream, String password)
\machinename\sharedfolderName\folderName is web content folder. We have process extract the skin file into the above said folder through web application.

Here's the code which extract the zip file.
using (ZipFile zip1 = ZipFile.Read(stagingFilePath))
{
if (zip1.Count > 0)
{
foreach (ZipEntry e in zip1)
{
    e.Extract(unpackDirectory, ExtractExistingFileAction.OverwriteSilently);
}
zip1.Dispose();
errorMessage = "Style Sheet file uploaded and published successfully.";
messageType = INFORMATION;
}
else
{
errorMessage = GetString(StringTokens.UploadStyleSheetZipFileIsEmpty, "Zip file is empty");
messageType = ERROR;
}
}

The error occurs at e.extract(unpackDirectory, ExtractExistingFileAction.OverwriteSilently); line, even when process run first time. The path of unpackDirectory is __\machinename\sharedfolderName\folderName.
The following users has permission on the web content folder (APSNET, IIS_USR and everyone - Full permission). Still I get this error.

Any help will be appreciated.