I need to periodically download, extract and save the contents of http://data.dot.state.mn.us/dds/det_sample.xml.gz to disk. Anyone have experience downloading gzipped files with C#?
Just use the HttpWebRequest class in the System.Net namespace to request the file and download it. Then use GZipStream class in the System.IO.Compression namespace to extract the contents to the location you specify. They provide examples.
You can use WebClient in System.Net to download:
WebClient Client = new WebClient ();
Client.DownloadFile("http://data.dot.state.mn.us/dds/det_sample.xml.gz", " C:\mygzipfile.gz");
then use #ziplib to extract
Edit: or GZipStream... forgot about that one
Try the SharpZipLib, a C# based library for compressing and uncompressing files using gzip/zip.
Sample usage can be found on this blog post:
using ICSharpCode.SharpZipLib.Zip;
FastZip fz = new FastZip();
fz.ExtractZip(zipFile, targetDirectory,"");
Here is a post I wrote last year that shows how to decompress a gzip file using C# and the built-in GZipStream class. http://blogs.msdn.com/miah/archive/2007/09/05/zipping-files.aspx
As for downloading it, you can use the standard WebRequest or WebClient classes in .NET.
How do you download over SSL?
(I know this isnt an answer, but i didnt want to create a whole new ? out of this, i'd like to enhance this existing ?)