DotNetZip: How to extract files, but ignoring the path in the zipfile?

后端 未结 4 1684
借酒劲吻你
借酒劲吻你 2021-02-14 03:33

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

4条回答
  •  心在旅途
    2021-02-14 03:58

    You'll need to remove the directory part of the filename just prior to unzipping...

    using (var zf = Ionic.Zip.ZipFile.Read(zipPath))
    {
        zf.ToList().ForEach(entry =>
        {
            entry.FileName = System.IO.Path.GetFileName(entry.FileName);
            entry.Extract(appPath);
        });
    }
    

提交回复
热议问题