tags:

views:

146

answers:

1

Hello, I've been using Windows Azure to create a document management system, and things have gone well so far. I've been able to upload and download files to the BLOB storage through an asp.net front end.

What I'm attempting to do now is allow users to upload a .zip file, and then take the files out of that .zip and save them as individual files. Problem is, I'm getting "ZipException was unhandled" "EOF in header" and I don't know why.

I'm using the ICSharpCode.SharpZipLib library which I've used for many other tasks and its worked great.

Here's the basic code: CloudBlob ZipFile = container.GetBlobReference(blobURI);

MemoryStream MemStream = new MemoryStream();

ZipFile.DownloadToStream(MemStream); ....

while ((theEntry = zipInput.GetNextEntry()) != null)

and it's on the line that starts with while that I get the error. I added a sleep duration of 10 seconds just to make sure enough time had gone by.

MemStream has a length if I debug it, but the zipInput does sometimes, but not always. It always fails.

Thanks for any help.

Dave

A: 

Just a random guess, but do you need to seek the stream back to 0 before you read it? Not sure if you're doing that already (or if it's necessary).

smarx
What I did was set .Position = 0, which did the trick ... it seems. I think your seek answer may have the same result.Still curious why its like that though, that doesn't seem logical to me.
david
Well, not all streams support seeking. For example, you might create a web request, and then use DownloadToStream() to transfer bits from Windows Azure storage into this web request. At the end of that, seeking back to the beginning doesn't make sense (the bits have already been sent).I think because you can't always seek back to the beginning, the storage client library does the only consistent thing it can do, which is leave the stream where it is.
smarx
I can see that but in the context of the other uses its not logical. I've used to the downloadtostream function in DownloadtoStream(Response) and that works fine. But maybe the response auto resets the position. dunno. at least it seems to be working.
david