如何在 C# 中从未压缩的 zip 中读取文件?

发布于 2024-07-09 09:33:19 字数 250 浏览 9 评论 0原文

我正在创建一个 PDA 应用程序,需要上传/下载大量小文件,我的想法是将它们收集到一个未压缩的 zip 文件中。

问题是:从 zip 中读取这些文件而不将它们分开是个好主意吗? 我怎样才能这样做呢? 或者解压它们更好?由于文件没有被压缩,我简单的想法是,也许从 zip 中读取它们或多或少与直接从文件系统中读取它们一样有效。谢谢

你的时间!

I´m creating a PDA app and I need to upload/download a lot of small files and my idea is to gather them in an uncompressed zip file.

The question is: It´s a good idea to read those files from the zip without separating them? How can I do so? Or is it better to unzip them? Since the files are not compressed my simple mind points that maybe reading them from the zip it´s more or less as efficient as reading them directly from the file system...

Thanks for you time!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

罗罗贝儿 2024-07-16 09:33:19

由于有两个不同的开源库(SharpZipLibDotNetZip Library) 来处理写入和 从 zip 文件中提取文件,为什么要担心自己做呢?

Since there are two different Open-source libraries (SharpZipLib and DotNetZip Library) to handle writing & extracting files from a zip file, why worry about doing it yourself?

霊感 2024-07-16 09:33:19

ewww - 不要使用 J#。

自 v1.7 起,DotNetZip 库在 .NET Compact Framework 2.0 及更高版本上运行。 它可以处理 ZIP 存档中压缩或未压缩文件的读取或写入。 源发行版包括一个 CF 示例应用程序。 这真的很简单。

ewww - don't use J#.

The DotNetZip library, as of v1.7, runs on the .NET Compact Framework 2.0 and above. It can handle reading or writing compressed or uncompressed files within a ZIP archive. The source distribution includes a CF example app. It's really simple.

不顾 2024-07-16 09:33:19

听起来好像您想使用存档对文件进行分组。

读取文件的角度来看,文件以一种或另一种方式处理几乎没有什么区别。 不过,您需要实现读取 zip 文件的功能。 即使您使用 James Curran 建议的库,也意味着额外的工作,这可能意味着额外的错误源。

上传文件的角度来看,这更有意义:上传者可以收集所需的所有文件,并且只需处理一次上传。 这减少了开销以及错误处理(如果一个上传失败,是否必须删除该组已上传的所有文件?)。

至于从存档中读取它们与直接从光盘中读取它们的效率:差异应该很小。 您(或您的 zip 库)需要解析一次 zip 目录结构,这非常简单。 剩下的就是将文件的一部分读入内存与将文件读入内存。

Sounds as if you want to use the archive to group your files.

From a reading the files point of view, it makes very little difference if the files are handled one way or the other. You would need to implement the ability to read zip files, though. Even if you use a lib like James Curran suggested, it means additional work, which can mean additional sources of error.

From the uploading the files point of view, it makes more sense: The uploader could gather all the files needed and would have to take care of only one single upload. This reduces overhead as well as error handling (if one uplaod fails, do you have to delete all files of this group already uploaded?).

As for the efficiency of reading them from the archive vs. reading them directly from the disc: The difference should be minimal. You (or your zip library) need to once parse the zip directory structure, which is pretty straight forward. The rest is reading part of a file into memory vs. reading a file into memory.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文