Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extra white spce at the end of downloaded file

Status
Not open for further replies.

ogborstad

Programmer
Jun 4, 2009
1
NO
I have an asp page with a file download. I notice that the size of the downloaded file is always one byte bigger than the original file. This extra byte is always a white space appended at the end (HEX value 00). This causes problems with corruption for some filetypes (i.e. Office 2007 documents opened through the converter program used in Office 2003). Also, this only happens in my client's environment which is running Windows 2000 and IE6. It's not an option to upgrade because of corporate policy. My code is working on XP/Vista.

The filetype, fileSize and file variables are fetched from a VB6 component. The file variable is assigned in a VB6 function like this:

Private Function IMessageServer_GetMessageAttachment(ByVal fileName As String) As Byte()
Dim FNr As Integer
Dim ThePath As String
ThePath = App.Path & "\" & fileName
FNr = FreeFile
Open ThePath For Binary Access Read Shared As #FNr
ReDim IMessageServer_GetMessageAttachment(FileLen(ThePat h))
Get #FNr, , IMessageServer_GetMessageAttachment
Close #FNr
End Function


Extra white space at the end of a file download
I have an asp page with a file download. I notice that the size of the downloaded file is always one byte bigger than the original file. This extra byte is always a white space appended at the end (HEX value 00). This causes problems with corruption for some filetypes (i.e. Office 2007 documents opened through the converter program used in Office 2003). Also, this only happens in my client's environment which is running Windows 2000 and IE6. It's not an option to upgrade because of corporate policy. My code is working on XP/Vista.

The filetype, fileSize and file variables are fetched from a VB6 component. The file variable is assigned in a VB6 function like this:

Code:

Private Function IMessageServer_GetMessageAttachment(ByVal fileName As String) As Byte()
Dim FNr As Integer
Dim ThePath As String
ThePath = App.Path & "\" & fileName
FNr = FreeFile
Open ThePath For Binary Access Read Shared As #FNr
ReDim IMessageServer_GetMessageAttachment(FileLen(ThePat h))
Get #FNr, , IMessageServer_GetMessageAttachment
Close #FNr
End Function


ASP code which makes the file available for download:

Response.ContentType = GetMIMEType(filetype)

Response.AddHeader "Content-Disposition", "inline; filename=" & filename

Response.AddHeader "Content-Length", fileSize

Response.BinaryWrite file
Response.Flush
Response.End

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top