In my machine I have installed Windows 7 along with IIS 7.5.
I have created virtual path as "TestAsp" ("C:\inetpub\wwwroot\TestAsp").
I am unable to download a file which more than 2 KB
I have used following code in a asp file to download a file
<%
strFilePath = "C:\inetpub\wwwroot\TestAsp\Bin\Test1big.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.FileExists(strFilePath) Then
set file = fso.GetFile(strFilePath)
Response.buffer = TRUE
Response.Expires = 0
Response.Clear
Response.ContentType = "application/octet-stream"
Response.AddHeader "Document", fso.GetFileName(strFilePath)
Response.AddHeader "Content-Length", file.size
Response.AddHeader "Content-Disposition", "attachment; FileName=" &
fso.GetFileName(strFilePath)
Const adTypeBinary = 1
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath
Response.BinaryWrite objStream.Read
objStream.Close
Set objStream = Nothing
Else
Response.Write("File " & strFilePath & " does not exist.")
End if
Set fso = Nothing
%>
During my further investigation I have found that the following line in the asp page was causing the problem
"Response.AddHeader "Content-Length", file.size"
Once I comment the above line from the asp page I was able to download a file which is more than 2 KB.
I want to download a file without commneting above said line.
Can you help me on this
Thx in advance
Zulfiqar