I would like to create a text file for export/download, like a *.csv, from an ASP.NET application. I know about Response.TransmitFile, but I want to do this without creating
When you say "Create a file for export", I am understanding that you want to make it downloadable to the browser. If that's the case, here's an example.
public void btnGo_Click (Object sender, EventArgs e)
{
Response.Clear();
string fileName= String.Format("data-{0}.csv", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss"));
Response.ContentType = "text/csv";
Response.AddHeader("content-disposition", "filename=" + fileName);
// write string data to Response.OutputStream here
Response.Write("aaa,bbb,ccc\n");
Response.End();
}
cite: RFC 4180