hi
i have a webpage in my application that allows users to download a file.
for that i hv written the following code:
Dim fullpath As String = filename
Dim name = Path.GetFileName(fullpath)
Dim ext = Path.GetExtension(fullpath)
Dim type As String = ""
Try
If Not IsDBNull(ext) Then
ext = LCase(ext)
End If
Select Case ext
Case ".txt"
type = "text/plain"
Case ".doc", ".rtf"
type = "Application/msword"
Case Else
type = "text/plain"
End Select
If (forceDownload) Then
Response.AppendHeader("content-disposition", _
"attachment; filename=" + name)
End If
If type <> "" Then
Response.ContentType = type
End If
Response.WriteFile(fullpath)
Response.End()
this code works fine ..but response.end() raises an ThreadAbortException.
also if i use HttpContext.Current.ApplicationInstance.CompleteRequest() or response.flush()
then the htmlcode of the current page also comes in the downloaded file.
can anyone suggest me an alternative
i also want to delete the file from the server as soon as it is downloaded.
for this i tried writing the
file.delete(filepath)
but if it is written before response.end the page keeps on processing and no dialog box appears.
if i write it after response.end it is not executed since the execution of the page ends.
can any one suggest something...
thanks in advance