// Read the file we are going to compress into a FileStream string filename = Program.x; FileStream infile = File.OpenRead(filename); byte[] buffer = new byte[infile.Length]; infile.Read(buffer, 0, buffer.Length); infile.Close(); // Create the output file FileStream outfile = File.Create(Path.ChangeExtension(filename, "zip")); // Compress the input stream and write it to the output FileStream GZipStream gzipStream = new GZipStream(outfile, CompressionMode.Compress); gzipStream.Write(buffer, 0, buffer.Length); gzipStream.Close();
inFile.CopyTo(gzipStream);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)