lpatnaik
Programmer
- Jul 11, 2002
- 53
hey i have a slight problem with dotnet file download. can you help me out. I am downloading a file by clicking on a likn in an aspx page. that i do by using the code:
Sub DownloadSelectedFile()
Dim strFilename As String = Request.Form("h_uc_Filename"
Dim fileInfo As FileInfo
Dim intStartPos As Long = 0, intFileSize As Long, intEndPos As Long
fileInfo = New FileInfo(strFilename)
intFileSize = fileInfo.Length
intEndPos = intFileSize
HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" & fileInfo.Name)
HttpContext.Current.Response.WriteFile(strFilename, intStartPos, intEndPos)
End Sub
But this code is downloadin the aspx file sometimes rather than downloading the reqd file (doc/xls). can you help me out.?
Sub DownloadSelectedFile()
Dim strFilename As String = Request.Form("h_uc_Filename"
Dim fileInfo As FileInfo
Dim intStartPos As Long = 0, intFileSize As Long, intEndPos As Long
fileInfo = New FileInfo(strFilename)
intFileSize = fileInfo.Length
intEndPos = intFileSize
HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" & fileInfo.Name)
HttpContext.Current.Response.WriteFile(strFilename, intStartPos, intEndPos)
End Sub
But this code is downloadin the aspx file sometimes rather than downloading the reqd file (doc/xls). can you help me out.?