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#?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
Try the SharpZipLib, a C# based library for compressing and uncompressing files using gzip/zip.
Sample usage can be found on this blog post:
The GZipStream class might be what you want.
To compress:
To Decompress:
Taken from 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.
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:
then use #ziplib to extract
Edit: or GZipStream... forgot about that one