Extracting zip file with nested files containing dots and spaces

时间:2015-10-06 08:39:37

标签: c# .net zip extract

i got this following zip file name System Update 1.2.4.zip

The file structure inside the file is as following:

System Update 1.2.4
  Files
  Software
  Changelog.txt

I'm using the following line to extract my file

ZipFile.ExtractToDirectory(zipPath, extractPath);

The zipPath and extractPath is correct, but i'm getting the following error:

An unhandled exception of type 'System.IO.IOException' occurred in System.IO.Compression.FileSystem.dll
Additional information: Zip entry name ends in directory separator character but contains data.

I couldn't find the error on MSDN, the error list for IOException listed there is:

The directory specified by destinationDirectoryName already exists. -or- The name of an entry in the archive is Empty, contains only white space, or contains at least one invalid character. -or- Extracting an archive entry would create a file that is outside the directory specified by destinationDirectoryName. (For example, this might happen if the entry name contains parent directory accessors.) -or- An archive entry to extract has the same name as an entry that has already been extracted from the same archive.

EDIT: i want to extract it without renaming the files

SOLVED:

I used DotNetZip to solve it. I couldn't find any solution using it with the .Net library System.IO.Compression.FileSystem.dll. The question here doesn't provide any solution for my problem. I don't have any of the 3 conditions listed in the answer.

Ionic.Zip.ZipFile zip = Ionic.Zip.ZipFile.Read(zipPath);
            Directory.CreateDirectory(extractPath);
                  foreach (ZipEntry en in zip)
                  {
                      en.Extract(extractPath, ExtractExistingFileAction.OverwriteSilently);
                  }

0 个答案:

没有答案