简体   繁体   English

使用ZipPackage列出Zip文件中的目录

[英]Listing directories in a Zip file using ZipPackage

How can I list directories in a zip file using ZipPackage ? 如何使用ZipPackage在zip文件中列出目录? I would like to work with the zip file as if it was a folder structure on disk, ie list files and directories at the current level, open some of the files as needed, then go into every folder, and so on recursively. 我想使用zip文件,就好像它是磁盘上的文件夹结构一样,即在当前级别列出文件和目录,根据需要打开一些文件,然后递归进入每个文件夹,依此类推。

If possible, I would like to avoid external dependencies and I am limited to .Net 4.0. 如果可能的话,我想避免外部依赖,并且我限于.Net 4.0。

EDIT: To make the question more concrete, assume I would like to create the following structure, that corresponds to the contents of the zip file: 编辑:为了使问题更具体,假设我想创建以下结构,该结构与zip文件的内容相对应:

interface IDirectory
{
  IList<IDirectory> SubDirectories {get; }
  IList<IFile> Files{get; }
  string Name {get; }
  //other methods
}

interface IFile
{
  string Name {get; }
  void UnZip (IStream stream);
}

ZipPackage似乎不能处理任意的zip档案,所以我想我的问题的答案是:不可能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM