Problem on download file via ASP Net

S

Sharon

When i download a dbf file to my local computer, the last few record of that
dbf file will full of funny character.

Here is my coding :

' Identify the file to download including its path.
Dim filepath As String =
Server.MapPath("\eClinicApp\VISITD.DBF")

' Identify the file name.
Dim filename As String = System.IO.Path.GetFileName(filepath)

Response.Clear()

' Specify the Type of the downloadable file.
Response.ContentType = "application/octet-stream"

' Set the Default file name in the FileDownload dialog box.
Response.AddHeader("Content-Disposition", "attachment;
filename=""" & filename & """")

Response.Flush()

' Download the file.
Response.WriteFile(filepath)

Anybody know what happen? pls help

Another question is can the file that i wanted to download in zipped format?
if can, can teach me how?

Best Regards
Rico Teh
 
J

Joerg Jooss

Sharon said:
When i download a dbf file to my local computer, the last few record
of that dbf file will full of funny character.

Here is my coding :

' Identify the file to download including its path.
Dim filepath As String =
Server.MapPath("\eClinicApp\VISITD.DBF")

' Identify the file name.
Dim filename As String =
System.IO.Path.GetFileName(filepath)

Response.Clear()

' Specify the Type of the downloadable file.
Response.ContentType = "application/octet-stream"

' Set the Default file name in the FileDownload dialog
box. Response.AddHeader("Content-Disposition",
"attachment;
filename=""" & filename & """")

Response.Flush()

' Download the file.
Response.WriteFile(filepath)

Anybody know what happen? pls help


I wouldn't say it's wrong, but flushing the response buffer before sending
the file seems weird to me. What happens if you swap these lines?
Another question is can the file that i wanted to download in zipped
format? if can, can teach me how?

You can use #ziplib for that. See
http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top