An error occurred while compressing the file "\\someWin11PC\somedatabase.gdb" into the archive: (32) The process cannot access the file because it is being used by another process:
An error occurred while compressing the file
Re: An error occurred while compressing the file
I tried on Windows 11 pro 21H2 it's the same problem.
Re: An error occurred while compressing the file
The process cannot access the file because it is being used by another process. Only Volume Shadow Copy can help here but the source is in another machine so it won't work.
--
Luis Cobian
Cobian Backup's creator
Luis Cobian
Cobian Backup's creator
Re: An error occurred while compressing the file
An error occurred while compressing the file "\\someWin11PC\somedatabase.gdb" into the archive: (32) The process cannot access the file because it is being used by another p rocess:
An error occurred while compressing the file "\\someWin11PC\somedatabase.gdb" into the archive: (32) The process cannot access the file because it is being used by another p rocess:
But I prepare ZIP
I wonder why it will not work if i use ZIP method but if i use 7zip method it works no error?
No error Backup is ok.
But I prepare ZIP
I wonder why it will not work if i use ZIP method but if i use 7zip method it works no error?
Last edited by techds on 31 Jan 2023, 05:15, edited 5 times in total.
Re: An error occurred while compressing the file
Seven zip and Zip are two separated libraries. Zip is trying to open the files perhaps with exclusive rights.
--
Luis Cobian
Cobian Backup's creator
Luis Cobian
Cobian Backup's creator
Re: An error occurred while compressing the file
So is there any permission I can change on the exe's in cobian reflector folder to run as Administrator so the zip will work?
By the way Sir Luis, I try this on PowerShell and the backup in zip is ok.
By the way Sir Luis, I try this on PowerShell and the backup in zip is ok.
I hope you can emulate this on your zip application extension, your the expert on this Please...Copy-Item -Path "\\someWin11PC\somedatabase.gdb" -Force -PassThru | Get-ChildItem |
Compress-Archive -DestinationPath "D:\cobiantest\somefolder.zip"
Re: An error occurred while compressing the file
The library I am using is a third part library. I could modify it but I really really won't like to do that. But I'll see what can be done.
--
Luis Cobian
Cobian Backup's creator
Luis Cobian
Cobian Backup's creator
Re: An error occurred while compressing the file
OK thank you very much sir Luis I'm looking forward to it.
By the way Sir Lius, what's the name of the third party library you are using if you don't mind? (SharpZipLib, .NET Zip, System.IO.Compression and etc.)
By the way Sir Lius, what's the name of the third party library you are using if you don't mind? (SharpZipLib, .NET Zip, System.IO.Compression and etc.)
Re: An error occurred while compressing the file
Yes, it's SharpZipLib
--
Luis Cobian
Cobian Backup's creator
Luis Cobian
Cobian Backup's creator
Re: An error occurred while compressing the file
Hello Sir Luis,
Do these settings, copy the files to a temp folder before it will do the zipping? Because I try this code and it works, no error.
The process cannot access the file because it is being used by another process.
Do these settings, copy the files to a temp folder before it will do the zipping? Because I try this code and it works, no error.
But if I don't copy the files to a temp folder, I get this error.static void Main(string[] args)
{
if (!System.IO.Directory.Exists(@"C:\Users\test\Desktop\ziptest\" + "\\TempZipFile\\"))
{
System.IO.Directory.CreateDirectory(@"C:\Users\test\Desktop\ziptest\" + "\\TempZipFile\\");
}
string sTargetFolderPath = (@"C:\Users\test\Desktop\ziptest\" + "\\TempZipFile\\");
string filePath = @"\\someWin11PC\somedatabase.gdb";
FileInfo fi = new FileInfo(filePath);
if (fi.Exists)
{
try
{
fi.CopyTo(sTargetFolderPath + fi.Name, true);
}
catch
{
System.IO.Directory.Delete(sTargetFolderPath);
Console.WriteLine("Could not copy files to temp folder.", "File Error");
return;
}
}
Console.WriteLine("Ready to zip");
Console.ReadKey();
try
{
string[] filenames = Directory.GetFiles(sTargetFolderPath);
using (ZipOutputStream s = new ZipOutputStream(File.Create(@"C:\Users\test\Desktop\ziptest\" + "techds" + ".zip")))
{
s.SetLevel(9); // 0-9, 9 being the highest compression
byte[] buffer = new byte[4096];
foreach (string file in filenames)
{
var entry = new ZipEntry(Path.GetFileName(file));
entry.DateTime = DateTime.Now;
s.PutNextEntry(entry);
using (FileStream fs = File.OpenRead(file))
{
int sourceBytes;
do
{
sourceBytes = fs.Read(buffer, 0,
buffer.Length);
s.Write(buffer, 0, sourceBytes);
} while (sourceBytes > 0);
}
}
s.Finish();
s.Close();
}
System.IO.Directory.Delete(@"C:\Users\test\Desktop\ziptest\" + "\\TempZipFile\\", true);
Console.WriteLine("Zip file techds.zip created.");
Console.ReadKey();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message.ToString(), "Zip Operation Error");
Console.ReadKey();
}
}
The process cannot access the file because it is being used by another process.