This article describes the method of using GZipStream to decompress data files in C#. Share it for your reference. The specific analysis is as follows:
GZipStream is used to read data from one stream and write to another stream. GZipStream cannot be written to other resources, such as files or memory, and can only be from stream to stream.
The general process of using GZipStream is as follows:
Open an existing file
Open/create the output file
Create a GZipStream object
Read the source file byte byte and pass it to GZipStream
Write to output file stream using GZipStream
String sourcefilename = FILETOBEUNCOMPRESSED; Filestream sourcefile = (sourcefilename); Filestream destinationfile = (outputfilename); GZipStream compressionstream = new GZipStream(sourcefile, ); int sourcebyte = (); while(sourcebyte != -1) { ((byte)sourcebyte); sourcebyte = (); }
I hope this article will be helpful to everyone's C# programming.