开发者

FTPWebRequest: trouble downloading GZipped files

I'm downloading xml files that are compressed using GZip using System.NET.FtpWebRequest.

The files I receive are about twice the size as the files on the server and System.IO.Compression.GZipStream does not like them. It ret开发者_JS百科urns the following error message:

System.IO.InvalidDataException : 
The magic number in GZip header is not correct. 
Make sure you are passing in a GZip stream.

The GZip web site suggests many problems are caused by downloading binary files as ASCII. However, I'm getting the same problem whether I set UseBinary to true or false on FtpWebRequest.

My decompression code runs fine on files manually downloaded with FileZilla.

As usual your help is greatly appreciated.


My bad. The problem is with how I'm saving the stream to disk. Not a problem with FtpWebRequest or GZip at all. Was using a StreamWriter to a text file (I inherited that piece). Writing the FtpResponse stream to a FileStream solves my issue.

Thanks for looking; sorry for wasting anyone's time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜