views:

13

answers:

1

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 returns 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.

A: 

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.

hoi polloi