An error occurred while compressing the file

Questions about Cobian Reflector
techds
Posts: 17
Joined: 23 Jan 2023, 10:30

Re: An error occurred while compressing the file

Post by techds »

I tried on Windows 11 pro 21H2 it's the same problem. :cry:

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:
User avatar
cobian
Site Admin
Posts: 5047
Joined: 31 Oct 2020, 01:25
Location: Sweden
Contact:

Re: An error occurred while compressing the file

Post by cobian »

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
techds
Posts: 17
Joined: 23 Jan 2023, 10:30

Re: An error occurred while compressing the file

Post by techds »

zip_method.jpg
zip_method.jpg (69.89 KiB) Viewed 7240 times
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:
global_zip_method.jpg
global_zip_method.jpg (77.05 KiB) Viewed 7240 times
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:
m7zip.png
m7zip.png (37.3 KiB) Viewed 7240 times
No error Backup is ok.


But I prepare ZIP :cry:

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.
techds
Posts: 17
Joined: 23 Jan 2023, 10:30

Re: An error occurred while compressing the file

Post by techds »

error
error
zip_method.jpg (69.89 KiB) Viewed 7241 times
error
error
global_zip_method.jpg (77.05 KiB) Viewed 7241 times
backup ok
backup ok
m7zip.png (37.3 KiB) Viewed 7241 times
User avatar
cobian
Site Admin
Posts: 5047
Joined: 31 Oct 2020, 01:25
Location: Sweden
Contact:

Re: An error occurred while compressing the file

Post by cobian »

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
techds
Posts: 17
Joined: 23 Jan 2023, 10:30

Re: An error occurred while compressing the file

Post by techds »

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.
Copy-Item -Path "\\someWin11PC\somedatabase.gdb" -Force -PassThru | Get-ChildItem |
Compress-Archive -DestinationPath "D:\cobiantest\somefolder.zip"
I hope you can emulate this on your zip application extension, your the expert on this Please...
User avatar
cobian
Site Admin
Posts: 5047
Joined: 31 Oct 2020, 01:25
Location: Sweden
Contact:

Re: An error occurred while compressing the file

Post by cobian »

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
techds
Posts: 17
Joined: 23 Jan 2023, 10:30

Re: An error occurred while compressing the file

Post by techds »

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.)
User avatar
cobian
Site Admin
Posts: 5047
Joined: 31 Oct 2020, 01:25
Location: Sweden
Contact:

Re: An error occurred while compressing the file

Post by cobian »

Yes, it's SharpZipLib
--
Luis Cobian
Cobian Backup's creator
techds
Posts: 17
Joined: 23 Jan 2023, 10:30

Re: An error occurred while compressing the file

Post by techds »

Hello Sir Luis,

Do these settings, copy the files to a temp folder before it will do the zipping?
zipcomp.jpg
zipcomp.jpg (64.25 KiB) Viewed 7156 times
Because I try this code and it works, no 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();
}
}
But if I don't copy the files to a temp folder, I get this error.
The process cannot access the file because it is being used by another process.
Post Reply