ExtractExistingFileAction.OverwriteSilently is not overwriting the files in a given folder

0

I have an update solution for an application that uses the DotNetZip API ( link ) 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 location where the files that are inside the zip (file) will be unzipped.

If the directory already has a file with the same name as it will be unzipped, the application is returning an error for the file already in the directory.

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

Should this OverwriteSilently method not overwrite the unzipped files silently (without user confirm request)?

Or, is there any way to force this override into the directory (of the -f type or something like that)?

If you have any other tips on how to do this, I'll be grateful.

    
asked by anonymous 04.04.2014 / 15:45

1 answer

1

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

  • The file is in use.
  • The program is not allowed to delete it before writing a new one.
  • To check both, try a quick test, it can be in the "Immediate Window" itself:

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

    I hope it helps ...

        
    30.06.2014 / 23:28