I have a StringBuilder
object which I have built with comma seperated values, which I would like to save as a .csv
file.
I know how to stream the data as CSV, but how can I physically save the data as a .csv
file, on the server?
Currently I stream the CSV like the following, where sb
is StringBuilder
:
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment;filename=List.csv")
Response.ContentType = "text/csv"
Response.Write(sb.ToString)
Response.End()