如何在不提取的情况下读取压缩文件夹中的文本文件 [英] How to read text file in zipped folder without extracting

查看:129
本文介绍了如何在不提取的情况下读取压缩文件夹中的文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我有一个压缩文件夹,其中有一个文本文件。

任何人都可以告诉我如何从文本文件中读取文本而不提取压缩文件夹。

Hello,
I have one zipped folder in that there is one text file .
can any one tell me How to read text from text file without extracting zipped folder.

推荐答案

假设您已解决问题并成功读取其中一个压缩文件的内容。基本上,你从zip中提取文件。看起来你问:如何提取文件而不提取。我理解,这听起来很神奇,但这是因为你对这个问题的表述没有明确的定义。由于您是软件开发人员,您需要能够提供更严格的陈述或问题。



最有可能的是,你的意思是不同的:如何提取一些压缩文件直接进入内存,避免创建和任何临时文件。那是对的吗?如果我的假设是错误的,我会感到很惊讶。



实现它的方法之一是使用开源DotNetZip。这在这里解释:

http://stackoverflow.com/questions/12715945/unzip-a-memorystream-contains-the-zip-file-and-get-the-files [ ^ ]。



-SA
Supposed you have your problem solved and successfully read the content of one of the zipped files. Essentially, you extracted the file from zip. It looks like you asking: "how to extract a file without extracting". I understand, it sound casuistic, but this is because your formulation of the problem has no certain well-defined meaning. As you are a software developer, you need to be able to provide more strict formulations of your statement or questions.

Most likely, you meant something different: how to extract some zipped file directly into memory, avoiding creation and any temporary files. Is that correct? I would be much surprised if my assumption was wrong.

One of the ways to achieve it is using open-source DotNetZip. This is explained here:
http://stackoverflow.com/questions/12715945/unzip-a-memorystream-contains-the-zip-file-and-get-the-files[^].

—SA


先生,你只能知道文件是怎么做的正在压缩或正在使用什么方法来压缩文件夹,因为当文件夹被压缩时,其中的每个文件都是单独压缩的。



您可以使用诸如< b> SharpZipLib 或 DotNetZip 解压缩文件并获取其中包含的各个文件的内容。此操作可以在内存中执行,您无需将文件存储到临时文件夹中。



SharpZipLib:http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx [ ^ ]



DotNetZip:http://dotnetzip.codeplex.com/ [ ^ ]
sir, you can only do so if you have knowledge that how the file is being compressed or what method is being used to compress it as when a folder is compressed every file in it is compressed separately.

You could use a library such as SharpZipLib or DotNetZip to unzip the file and fetch the contents of individual files contained inside. This operation could be performed in-memory and you don't need to store the files into a temporary folder.

SharpZipLib:http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx[^]

DotNetZip:http://dotnetzip.codeplex.com/[^]


这篇关于如何在不提取的情况下读取压缩文件夹中的文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆