1
Vote

"Path is empty" when extracting in a linux system.

description

When using the following code:
 
ZipFile zip = ZipFile.Read(ms);
zip.ExtractAll(LatestPath);
 
An "Path is empty" exception message is triggered by that DotNetZip tries to pass "" to Directory.Create() in ZipEntry.Extract, line 760.
 
The cause is that the variable targetFileName contain the path using "\" as directory separator. When run on linux the path is interpreted as a single filename making the directory path "".
 
I would guess it could be fixed in the method ValidateOutput() in the same file line 1417:
  • outFileName = outFileName.Replace("/","\");
  • outFileName = outFileName.Replace('/', Path.DirectorySeparatorChar);
     
    It works but someone who knows it should have a look at it.

file attachments

comments

Daxed wrote Feb 14 at 10:11 PM

The main issue is:

The Dotnetzip library can't extract files on the Linux/MAC platform (including iOS). You get the error, "Argument Exception: Path is empty."

The whole library works fine except that the class ZipExtract has hardcoded replacing "/" with "\". Changing this behaviour to proper pathing allows the whole library to work fine.

I have attached a file with the necessary changes for ZipEntry.Extract.cs, and a compiled version of the zip library. This minor error with major ramifications has gone overlooked for years.

edgarrc wrote Mar 13 at 5:51 PM

Thank you, I hope this fix is already merged on main stream, worked perfectly on linux-mono.