Private Sub DownloadFile(ByVal fullpath As String, ByVal forceDownload As Boolean) ' Dim path As Path Dim name = Path.GetFileName(fullpath) Dim ext = Path.GetExtension(fullpath) Dim type As String = "" If Not IsDBNull(ext) Then ext = LCase(ext) End If Select Case ext Case ".htm", ".html" type = "text/HTML" Case ".txt" type = "text/plain" Case ".doc", ".rtf" type = "Application/msword" Case ".csv", ".pdf" type = "Application/pdf" Case ".zip", ".ZIP" type = "Application/zip" Case ".zip", ".csv" type = "text/csv" Case Else type = "text/plain" End Select ''Dim req As New WebClient ''Dim response As HttpResponse ''response = HttpContext.Current.Response ''response.Clear() ''response.ClearContent() ''response.ClearHeaders() ''response.Buffer = True ''response.AddHeader("Content-Disposition", "attachment; filename=" + name) ''response.ContentType = "application/octet-stream" ' ''response.BinaryWrite(Buffer) ''response.Flush() ''response.End() If (forceDownload) Then Response.AppendHeader("content-disposition", "attachment; filename=" + name) End If If type <> "" Then Response.ContentType = type End If Response.WriteFile(fullpath) Response.Flush() Response.End() End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)