1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
Private Sub DataListFichier_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles DataListFichier.ItemCommand
If e.CommandName = "Fichier" Then
Response.Clear()
Dim NomFichier
Me.DataSetFichier1 = SQLServer.Projets_Fichiers_DataSet(Session("IDProjet"), Me.SqlConnection1)
NomFichier = Me.DataSetFichier1.Tables(0).Rows(0).Item("NomDoc")
Response.AppendHeader("content-disposition", _
"attachment; filename=" + NomFichier)
Dim ext As String
Dim type As String
ext = NomFichier.Substring(NomFichier.LastIndexOf(".") + 1)
Select Case ext
Case ".htm", ".html"
type = "text/HTML"
Case ".txt"
type = "text/plain"
Case ".doc", ".rtf"
type = "Application/msword"
Case ".csv", ".xls"
type = "Application/x-msexcel"
Case Else
type = "text/plain"
End Select
Response.ContentType = type
'Response.AddHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0")
'Response.AddHeader("Pragma", "no-cache")
' Response.AddHeader("Expires", 0)
Response.WriteFile((Request.PhysicalApplicationPath & "/" & NomFichier))
End If
End Sub |
Partager