I am using C# to programatically compress an xml file. Compression works fine, but when I gunzip the file from the command line, the extension has been dropped. Why would this be?
The destination file coming in has the gz extension while the source file has an xml extension.
Here is my compression code:
using (FileStream input = File.OpenRead(filename))
{
using (var raw = File.Create(destFilename))
{
using (Stream gzipStream = new GZipStream(raw, CompressionMode.Compress))
{
byte[] buffer = new byte[4096];
int n;
while ((n = input.Read(buffer, 0, buffer.Length)) != 0)
{
gzipStream.Write(buffer, 0, n);
}
}
}
}
This also happens when I use a 3rd party library (SharpLibZip) to compress the file.
How do I keep the extension in the compressed zip file?