System.IO.Compression.GZipStream.Flush C# (CSharp) Method

Flush() public method

public Flush ( ) : void
return void
        public override void Flush()
        {
            CheckDeflateStream();
            _deflateStream.Flush();
            return;
        }

Usage Example

Exemplo n.º 1
0
        public static void Compress(string FileToCompress, string CompressedFile)
        {
            byte[] buffer = new byte[1024 * 1024]; // 1MB

            using (System.IO.FileStream sourceFile = System.IO.File.OpenRead(FileToCompress))
            {
                using (System.IO.FileStream destinationFile = System.IO.File.Create(CompressedFile))
                {
                    using (System.IO.Compression.GZipStream output = new System.IO.Compression.GZipStream(destinationFile,
                                                                                                          System.IO.Compression.CompressionMode.Compress))
                    {
                        int bytesRead = 0;
                        while (bytesRead < sourceFile.Length)
                        {
                            int ReadLength = sourceFile.Read(buffer, 0, buffer.Length);
                            output.Write(buffer, 0, ReadLength);
                            output.Flush();
                            bytesRead += ReadLength;
                        } // Whend

                        destinationFile.Flush();
                    } // End Using System.IO.Compression.GZipStream output

                    destinationFile.Close();
                } // End Using System.IO.FileStream destinationFile

                // Close the files.
                sourceFile.Close();
            } // End Using System.IO.FileStream sourceFile
        }     // End Sub CompressFile
All Usage Examples Of System.IO.Compression.GZipStream::Flush