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.ContentType = "text/csv"
Response.AddHeader("Content-Disposition", "attachment; filename=\" & FileName & "\")