unknown
2006-09-21 06:56:02 UTC
我用如下的函數讓使用者從網頁下載檔案,
SavaName 是預設的儲存檔名,FileName 是欲讓人下載的檔案,
SaveName = "C:\Data\20060921.txt",但是下載存檔路徑卻總是預設在桌面,
請問可以程式指定使用者下載路徑嗎?
請各位先進賜教,謝謝。
Public Sub DownLoadFile(ByVal WebForm As System.Web.UI.Page, ByVal SaveName
As String, ByVal FileName As String)
'===------
WebForm.Response.ClearHeaders()
WebForm.Response.Clear()
WebForm.Response.Expires = 0
WebForm.Response.Buffer = True
WebForm.Response.AddHeader("Accecpt-Language", "zh-tw")
WebForm.Response.AddHeader("content-disposition",
"attachment;filename=" & Chr(34) & System.Web.HttpUtility.UrlEncode(SaveName,
System.Text.Encoding.UTF8) & Chr(34) & "")
WebForm.Response.ContentType = "Application/octet-stream"
WebForm.Response.WriteFile(FileName)
WebForm.Response.End()
'===------
End Sub
SavaName 是預設的儲存檔名,FileName 是欲讓人下載的檔案,
SaveName = "C:\Data\20060921.txt",但是下載存檔路徑卻總是預設在桌面,
請問可以程式指定使用者下載路徑嗎?
請各位先進賜教,謝謝。
Public Sub DownLoadFile(ByVal WebForm As System.Web.UI.Page, ByVal SaveName
As String, ByVal FileName As String)
'===------
WebForm.Response.ClearHeaders()
WebForm.Response.Clear()
WebForm.Response.Expires = 0
WebForm.Response.Buffer = True
WebForm.Response.AddHeader("Accecpt-Language", "zh-tw")
WebForm.Response.AddHeader("content-disposition",
"attachment;filename=" & Chr(34) & System.Web.HttpUtility.UrlEncode(SaveName,
System.Text.Encoding.UTF8) & Chr(34) & "")
WebForm.Response.ContentType = "Application/octet-stream"
WebForm.Response.WriteFile(FileName)
WebForm.Response.End()
'===------
End Sub