Unzip the file while reading

I have hundreds of CSV files. This is great because they take up very little space, but when it is time to use them, I have to make some space on my HD and unzip them before I can process it. I was wondering if using .NET it is possible to unzip a file while reading. In other words, I would like to open the zip file, start unpacking the file and, as we go, process the file.

This way, I don’t need the extra space on my disk. Any ideas or suggestions?

+3
source share
4 answers

Yes. Zip is a streaming format, which means that you can use the data when unpacking it, rather than unpacking everything first.

In the .net System.IO.Compression classes you can apply the same compression used in zip files (Deflate and GZip) for any stream that you like, but if you want to work with actual files in zip format, you will need a third party library like this one (sharpziplib).

+5
source

A better solution might be to have the files unzipped to disk, but enable file system compression. Thus, you will simply read the CSV files, and the OS will take care not to take up too much space.

Anyhoo, , , GZipStream .

+1

sharpziplib - . - item Read , .

+1

zip , GZ GZipSteam ( ), , System.IO.Compression - 2 ( - DEFLATE).

EDIT: ZipPackage. , , , , , .

, # ziplib.

0

Source: https://habr.com/ru/post/1752952/


All Articles