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

后端 未结 4 1677
借酒劲吻你
借酒劲吻你 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:55

    While you can't specify it for a specific call to Extract() or ExtractAll(), the ZipFile class has a FlattenFoldersOnExtract field. When set to true, it flattens all the extracted files into one folder:

    var flattenFoldersOnExtract = zip.FlattenFoldersOnExtract;
    zip.FlattenFoldersOnExtract = true;
    zip.ExtractAll();
    zip.FlattenFoldersOnExtract = flattenFoldersOnExtract;
    

提交回复
热议问题