I have a solution for updating an application that uses the API DotNetZip (http://dotnetzip.codeplex.com/) for handling ZIP files. One method is to overwrite files in certain folders as follows.
ZipFile zipFile = ZipFile.Read(file);
{
foreach (ZipEntry zipEntry in zipFile)
{
zipEntry.Extract(@"C:\IASD\CantinaEscolar", ExtractExistingFileAction.OverwriteSilently);
}
}
Where: @ "c: \ SDA \ CantinaEscolar"
is where are unzipped the files inside the zip (files)
.
Now, if the directory already contains a file with the same name that will be unpacked, the application is returning an error related to the file already exists in the directory.
System.IO.IOException: The file 'c:\IASD\CantinaEscola\nomedoarquivo.exe' already exists
OverwriteSilently
This method should not override the unzipped files silently (without requesting user confirmation)?
Or: Is there any way to force this overwritten within the directory (-type f or something)?
If you possess any other tips on how to accomplish this task, I will be grateful.
OverwriteSilently can overwrite a file. It won't throw an Exception if the file is already present even if the the file is readonly.
What it cannot do is:
The latter could very well be the case for the file "nomedoarquivo.exe". This executable could be running while trying to overwrite.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With