Trying to extract files to a given folder ignoring the path in the zipfile but there doesn't seem to be a way.
This seems a fairly basic requirement given all the other good stuff implemented in there.
What am i missing ?
code is -
using (Ionic.Zip.ZipFile zf = Ionic.Zip.ZipFile.Read(zipPath))
{
zf.ExtractAll(appPath);
}
You'll need to remove the directory part of the filename just prior to unzipping...
While you can't specify it for a specific call to
Extract()
orExtractAll()
, theZipFile
class has aFlattenFoldersOnExtract
field. When set to true, it flattens all the extracted files into one folder:That will fail if there are 2 files with equal filenames. For example files\additionalfiles\file1.txt temp\file1.txt
First file will be renamed to file1.txt in the zip file and when the second file is trying to be renamed an exception is thrown saying that an item with the same key already exists
You can use the overload that takes a stream as a parameter. In this way you have full control of path where the files will be extracted to.
Example: