读取包含许多.gz文件的.gz文件 [英] Reading a .gz file which contain many .gz files

查看:248
本文介绍了读取包含许多.gz文件的.gz文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候

我有一个.gz文件,其中包含几个.gz文件.例如file1.gz包含a.gz,b.gz,c.gz.

我想即时读取a.gz文件的内容-也就是说,我不想将其解压缩然后再读取它们.我能够读取不包含.gz的.gz文件,但无法弄清楚如何读取包含.gz文件的.gz文件.

以下代码段将读取gz文件的内容,前提是该文件不包含任何gz.
如何读取包含.gz文件的文件?

Greetings

I have a .gz file which contains several .gz files. For example file1.gz contains a.gz, b.gz, c.gz.

I want to read the contents of a.gz files on the fly - that is, I don''t want to decompress them and then read them. I am able to read a .gz file which does not contain a .gz but cannot figure out how to read a .gz file which contains .gz files.

The following snippet will read the contents of a gz file provided it does not contain any gz.
How can I read a file which contains .gz files?

For Each fi As FileInfo In di.GetFiles("*.gz")

  fullPath = dirpath + "\" + fi.ToString

  dirInstream = New GZipStream(File.OpenRead(fullPath), CompressionMode.Decompress)
  reader = New StreamReader(dirInstream)

  Do While Not readLine Is Nothing
                    	
                    	
    '--- Do some work on readLine

     readLine = reader.ReadLine

    reader.Close()
Next

推荐答案

嵌入的gz文件将被解压缩为gz文件.然后,您需要将这些文件写入文件系统,然后将其解压缩.您的代码不会魔术般地递归这些文件,只有在您要求它执行时,它才会这样做
The embedded gz files will be decompressed as gz files. You then need to write those files to the file system, and decompress them. Your code will not recurse over these files by magic, it will only do it if you ask it to


这篇关于读取包含许多.gz文件的.gz文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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