I am serializing an object with the following code, which uses GZip and Xml:
FileStream fs = new FileStream(destinationfolder + "/myFileName.gz",
FileMode.Create, FileAccess.Write);
using (var gz = new GZipStream(fs, CompressionMode.Compress)) {
var serializer = new XmlSerializer(typeof(MyObjectType));
serializer.Serialize(gz, myObject);
}
That works fine, with one single problem: The user can open the .gz
file with 7Zip (after setting the file association), but then he can't just doubleclick the shown xml inside the .gz
file, since it doesn't have the .xml
extension (although the content is actually there, xml formatted and all).
Question is: "How can I serialize XML to a GZipStream
so that the .xml
extension is saved with the file, inside the .gz
archive?" I'm using .NET 4.0.
Thanks for reading.