By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,847 Members | 3,068 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,847 IT Pros & Developers. It's quick & easy.

http download corrupting zip file

P: n/a
I have an http download that streams a zip file to client, after download I
am getting "Error [file name] start of central directory not found; Zip file
corrupt. Possible casue: file transfer error."

Ring any bells? Here's the asp code, thanks in advance!!

Derrick

...
Response.ContentType = "application/zip"
Response.AddHeader "Content-Disposition", "attachment; filename=" &
downloadFile

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile downloadPath

Response.BinaryWrite objStream.Read

objStream.Close
Set objStream = Nothing
Response.End
Jul 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
more info, in particular, I can reproduce this, the code below generates a
different size file on the client, the download file on the server is 63.7
MB (66,848,355 bytes), when I download it grows to 63.7 MB (66,851,533
bytes), consistently. ??

Thanks in advance for any help!

Derrick

"Derrick" <de*********@excite.com> wrote in message
news:Oh**************@TK2MSFTNGP09.phx.gbl...
I have an http download that streams a zip file to client, after download I am getting "Error [file name] start of central directory not found; Zip file corrupt. Possible casue: file transfer error."

Ring any bells? Here's the asp code, thanks in advance!!

Derrick

...
Response.ContentType = "application/zip"
Response.AddHeader "Content-Disposition", "attachment; filename=" & downloadFile

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile downloadPath

Response.BinaryWrite objStream.Read

objStream.Close
Set objStream = Nothing
Response.End

Jul 21 '05 #2

P: n/a
I'm doing similar with similar sized files...my code is:

MyFileStream = New FileStream(pathspec & filespec, FileMode.Open)
FileSize = MyFileStream.Length

Dim Buffer(CInt(FileSize)) As Byte
MyFileStream.Read(Buffer, 0, CInt(FileSize))
MyFileStream.Close()

Response.BufferOutput = True

Response.ContentType = "application/asp-unknown"

Response.AddHeader("content-disposition", "attachment; filename=" &
filespec)

Response.BinaryWrite(Buffer)

Response.Flush()
Response.End()

Jeff

"Derrick" <de*********@excite.com> wrote in message
news:Oh**************@TK2MSFTNGP09.phx.gbl...
I have an http download that streams a zip file to client, after download I am getting "Error [file name] start of central directory not found; Zip file corrupt. Possible casue: file transfer error."

Ring any bells? Here's the asp code, thanks in advance!!

Derrick

...
Response.ContentType = "application/zip"
Response.AddHeader "Content-Disposition", "attachment; filename=" & downloadFile

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile downloadPath

Response.BinaryWrite objStream.Read

objStream.Close
Set objStream = Nothing
Response.End

Jul 21 '05 #3

P: n/a
Jeff, thanks, I looked at yours which appears to be asp.net, rewrote mine a
bit, this modified code downloads the file with the correct size..
interesting, I'm guessing it's the clear and flush around the binary write..

'Set the content type to the specific type that you are sending.
Set objFilesystem =
Server.CreateObject("Scripting.FileSystemObject")
Set objFilestream = objFilesystem.GetFile(downloadPath)
intFilelength = objFilestream.size

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile downloadPath

Response.Clear
Response.ContentType = "octet-stream" '"application/zip"
Response.AddHeader "Content-Disposition", "attachment; filename=" &
downloadFile
Response.AddHeader "Content-Length", intFilelength
Response.BinaryWrite objStream.Read(intFileLength)
Response.Flush
Response.End

objStream.Close
Set objStream = Nothing
"Jeff Dillon" <je**@removeemergencyreporting.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I'm doing similar with similar sized files...my code is:

MyFileStream = New FileStream(pathspec & filespec, FileMode.Open)
FileSize = MyFileStream.Length

Dim Buffer(CInt(FileSize)) As Byte
MyFileStream.Read(Buffer, 0, CInt(FileSize))
MyFileStream.Close()

Response.BufferOutput = True

Response.ContentType = "application/asp-unknown"

Response.AddHeader("content-disposition", "attachment; filename=" &
filespec)

Response.BinaryWrite(Buffer)

Response.Flush()
Response.End()

Jeff

"Derrick" <de*********@excite.com> wrote in message
news:Oh**************@TK2MSFTNGP09.phx.gbl...
I have an http download that streams a zip file to client, after
download I
am getting "Error [file name] start of central directory not found; Zip file
corrupt. Possible casue: file transfer error."

Ring any bells? Here's the asp code, thanks in advance!!

Derrick

...
Response.ContentType = "application/zip"
Response.AddHeader "Content-Disposition", "attachment;

filename=" &
downloadFile

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile downloadPath

Response.BinaryWrite objStream.Read

objStream.Close
Set objStream = Nothing
Response.End


Jul 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.