Client download .csv file from server using Response.TransmitFile
I am using the code below to enable clients to download a .csv file from my server.
The problem I am having is that when the file is saved to the client computer the file name is prefixed and suffixed with an underscore which leads to a file type of .csv_ which is obviously not a recognised file type.
How can I strip the underscores from the file name at the transmit stage?
Dim FileName As String = LstBox1.SelectedItem.ToString
Dim FilePath As String = "~/temp" & FileName
Response.Clear()
Response.ContentType = "text/csv"
Response.AddHeader("Content-Disposition", "attachment; filename=\" & FileName & "\")
Response.TransmitFile(FilePath)
Response.End()
MySQL ServerASP.NET Programming
Last Comment
taylor99
8/22/2022 - Mon
Kyle Abrahams
call replace inline on the filename.
Response.AddHeader("Content-Disposition", "attachment; filename=\" & FileName.Replace("_","") & "\")
Response.AddHeader("Conten