0
Digg me

‘ Stream File Content to Browser

Sub Download(ByVal sPath As String, ByVal iFormCode As Integer, ByVal sExt As String)

Dim sFileName As String
sFileName = CType(iFormCode, String) & “.” & sExt
‘Dim filename As String = sPath
Response.Clear()
If sExt.ToLower = “pdf” Then
Response.ContentType = “application/pdf”
ElseIf sExt.ToLower = “doc” Then
Response.ContentType = “application/doc”
End If
If File.Exists(sPath) Then
Response.AddHeader(“Content-Disposition”, “attachment; filename=”"” & sFileName & “”"”)
Response.WriteFile(sPath)
Response.Flush()
Else
Page.RegisterStartupScript(“notfound”, “[javascript function]“)
End If

End Sub