How can I used ReadAllLines with gzipped file

ManInMoon

Is there a way to use the one-liner ReadAllLines on a gzipped file?

var pnDates = File.ReadAllLines("C:\myfile.gz");

Can I put GZipStream wrapper around the file some how?

CodeCaster

No, File.ReadAllLines() treats the file specified as text file. A zipfile isn't that. It's trivial to do it yourself:

public IEnumerable<string> ReadAllZippedLines(string filename)
{
    using (var fileStream = File.OpenRead(filename))
    {
        using (var gzipStream = new GZipStream(fileStream, CompressionMode.Decompress))
        {
            using (var reader = new StreamReader(gzipStream)) 
            {
                yield return reader.ReadLine();
            }
        }
    }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

File.ReadAllLines或流阅读器

来自分类Dev

从File.ReadAllLines()结果中获取行号

来自分类Dev

C#-“路径中的非法字符” File.ReadAllLines

来自分类Dev

使用 File.ReadAllLines 验证 DataGridView 中的列?

来自分类Dev

File.ReadAllLines() 无法从 Excel 打开的文件中读取

来自分类Dev

How can I create a template version of this method that is used when template parameter is std::vector

来自分类Dev

How can I delete a user in linux when the system says its currently used in a process

来自分类Dev

How can I recover space "used" when system crashed during Sdelete?

来自分类Dev

How can I print contents of file given filename as stdin in bash?

来自分类Dev

Using Gradle, how can I ensure that a file exists at a certain location?

来自分类Dev

How to parse a text file (CSV) into haskell so I can operate on it?

来自分类Dev

How can I recursively find the *directories* containing a file of a certain type?

来自分类Dev

How can I loop through values in my json file?

来自分类Dev

How can I work with a .csv file using Java Spring Resttample?

来自分类Dev

How can I find my browser web log file?

来自分类Dev

How can I preserve the value of my parameters through a function so it can be used multiple times with its initial value?

来自分类Dev

File.ReadLines()和File.ReadAllLines()有什么区别?

来自分类Dev

需要帮助来了解Microsoft对File.ReadLines和File.ReadAllLines的解释

来自分类Dev

How can I use sed to make thousands of substitutions in a file using a reference file?

来自分类Dev

How can i get from a FileInfo[] the file full name full directory including the file extension?

来自分类Dev

与LINQ一起使用时,是否会延迟加载File.ReadAllLines?

来自分类Dev

File.readAllLines或Files.lines方法中哪个更快用于文件读取?

来自分类Dev

有没有办法在File.ReadAllLines方法中使用通配符(*)?

来自分类Dev

What can I use to monitor memory used by a single program?

来自分类Dev

What can I use to monitor memory used by a single program?

来自分类Dev

How can i extract the image out of 'System.Drawing.Bitmap' to file via windbg?

来自分类Dev

How can I populate Liquibase parameter values from an external properties file?

来自分类Dev

How can I read float data from a binary file using R

来自分类Dev

How can I import a model object file into my watch extension if it has a lot of dependencies

Related 相关文章

  1. 1

    File.ReadAllLines或流阅读器

  2. 2

    从File.ReadAllLines()结果中获取行号

  3. 3

    C#-“路径中的非法字符” File.ReadAllLines

  4. 4

    使用 File.ReadAllLines 验证 DataGridView 中的列?

  5. 5

    File.ReadAllLines() 无法从 Excel 打开的文件中读取

  6. 6

    How can I create a template version of this method that is used when template parameter is std::vector

  7. 7

    How can I delete a user in linux when the system says its currently used in a process

  8. 8

    How can I recover space "used" when system crashed during Sdelete?

  9. 9

    How can I print contents of file given filename as stdin in bash?

  10. 10

    Using Gradle, how can I ensure that a file exists at a certain location?

  11. 11

    How to parse a text file (CSV) into haskell so I can operate on it?

  12. 12

    How can I recursively find the *directories* containing a file of a certain type?

  13. 13

    How can I loop through values in my json file?

  14. 14

    How can I work with a .csv file using Java Spring Resttample?

  15. 15

    How can I find my browser web log file?

  16. 16

    How can I preserve the value of my parameters through a function so it can be used multiple times with its initial value?

  17. 17

    File.ReadLines()和File.ReadAllLines()有什么区别?

  18. 18

    需要帮助来了解Microsoft对File.ReadLines和File.ReadAllLines的解释

  19. 19

    How can I use sed to make thousands of substitutions in a file using a reference file?

  20. 20

    How can i get from a FileInfo[] the file full name full directory including the file extension?

  21. 21

    与LINQ一起使用时,是否会延迟加载File.ReadAllLines?

  22. 22

    File.readAllLines或Files.lines方法中哪个更快用于文件读取?

  23. 23

    有没有办法在File.ReadAllLines方法中使用通配符(*)?

  24. 24

    What can I use to monitor memory used by a single program?

  25. 25

    What can I use to monitor memory used by a single program?

  26. 26

    How can i extract the image out of 'System.Drawing.Bitmap' to file via windbg?

  27. 27

    How can I populate Liquibase parameter values from an external properties file?

  28. 28

    How can I read float data from a binary file using R

  29. 29

    How can I import a model object file into my watch extension if it has a lot of dependencies

热门标签

归档