Hi,
I've tested your code and I changed the following to make it work for me:
When compressing you can set the Filter of the SaveFileDialog to "zip" instead of changing the extension afterwards:
OpenFileDialog op = new OpenFileDialog();
op.ShowDialog();
string filename = op.FileName;
SaveFileDialog sv = new SaveFileDialog();
sv.Filter = "Zip files|*.zip";
sv.ShowDialog();
string savefile = sv.FileName;
FileStream infile = File.OpenRead(filename);
byte[] buffer = new byte[infile.Length];
infile.Read(buffer, 0, buffer.Length);
infile.Close();
FileStream outfile = File.Create(savefile);
GZipStream gzipStream = new GZipStream(outfile, CompressionMode.Compress, false);
gzipStream.Write(buffer, 0, buffer.Length);
gzipStream.Close();
gzipStream.Dispose();
When decompressing you need to change "DeflateStream" to "GZipStream". So instead of
DeflateStream deflateStream = new DeflateStream(infile, CompressionMode.Decompress);
just use:
GZipStream deflateStream = new GZipStream(infile, CompressionMode.Decompress);