原本使用的下載方式會造成 檔案下載時檔案名稱亂碼。
因此變更檔案下載的方式,並且將檔案名稱做UrlEncode。
Dim filePath As String = "c:/123檔案.txt"
Dim wc As WebClient = New WebClient()
Dim byteFile() As Byte = Nothing
byteFile = wc.DownloadData(filePath)
Response.AppendHeader("content-disposition", "attachment;filename=" + "123檔案名稱")
HttpContext.Current.Server.UrlEncode(docPhysicalName)
Response.ContentType = "application/octet-stream"
Response.BinaryWrite(byteFile)
Response.End()
參考資料:
http://bob.logdown.com/posts/94996-aspnet-file-download
Response.WriteFile 檔案下載方式一
## System.Net.WebClient.DownloadData 檔案下載方式二
亂碼處理的參考資料:
0 意見: