从.tar.gz文件中提取一个已知文件 [英] Extract one known file from a .tar.gz file

查看:57
本文介绍了从.tar.gz文件中提取一个已知文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我无法从.tar.gz文件中提取特定文件。

我想提取a.tar.gz文件中的一个已知文件。我知道文件(known.txt)存在于.tar.gz(test.tar.gz)文件中,所以我只想将文件解压缩到临时位置而不进行任何搜索或浏览整个文件。



我能够从.zip文件中提取一个文件,但是当我使用相同的代码从.tar.gz文件中提取时,它给出了错误中央目录结束无法找到记录。



我理解.zip dll无法从.tar.gz中提取文件。



如果有人帮我这个就好了。



问候,Surya

Hi,

I am in trouble of extracting a specific file from a .tar.gz file.
I want to extract one known file from a.tar.gz file. I know the file(known.txt) exist in that .tar.gz(test.tar.gz) file, so i just want to extract the file to temporary location without any search or going through the entire file.

I can able to extract one file from .zip file but when I use same code to extract from .tar.gz file it gives me error "End of Central Directory record could not be found."

I understand the .zip dll will not help to extract file from .tar.gz.

It would be great if someone help me on this one.

Regards, Surya

推荐答案

TAR 文件只是附加在一起的所有其他文件的一个大文件, GZ 只是压缩1个文件,所以你必须解压缩所有文件以提取你想要的东西(当然是你想要的文件的开头)所以你不能只提取你想要的文件,因为格式不允许它。 />


尝试使用以下组件: http://icsharpcode.github.io/SharpZipLib / [ ^ ]
TAR files are just one big file of all your other files appended together, GZ just compresses that 1 file, so you have to decompress all the file to extract what you want (up to the start of the file you want of course) so you can't just extract the file you want since the format does not allow it.

Try using a component like : http://icsharpcode.github.io/SharpZipLib/[^]


这篇关于从.tar.gz文件中提取一个已知文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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