Extractexistingfileaction.Overwritesilently is not overwriting the files in a particular folder

Asked

Viewed 250 times

0

I have an update solution for an application that uses the Dotnetzip API (http://dotnetzip.codeplex.com/) for handling ZIP files. One of the methods used 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:\IASD\CantinaEscolar" is the place where the files that are inside the zip will be unzipped (file).

But if the directory already has a file with the same name as the one that will be unzipped, the application is returning an error regarding the file already exists in the directory.

System.IO.IOException: The file 'c:\IASD\CantinaEscola\nomedoarquivo.exe' already exists.

That method OverwriteSilently should not overwrite uncompressed files silently (no user confirmation request)?

Or: Is there any way to force this superscript into the directory (type -f or something similar)?

If you have any other tips on how to accomplish this task, I will be grateful.

1 answer

1

I should overwrite yes, but I can imagine two possible issues that might prevent you from overwriting the file that you might try to verify:

  1. The file is in use.
  2. The program is not allowed to delete it before writing a new.

To check both, try a test quickly, can be in the "Immediate Window itself":

File.Delete(@"c:\IASD\CantinaEscola\nomedoarquivo.exe");

I hope it helps...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.