M
maria.elmvang
Hi all,
I need my code to be able to generate and save an csv-file without
being prompted by a dialogue box, but I don't know if such a thing is
possible. I've found out how to generate the file without problems,
but I cannot seem to make it save the file to a predetermined
location. Is such a thing even possible?
The code I use to generate and open the file is below
private void CreateResponse(string QueryName, string CSVContent)
{
System.Text.Encoding encoding =
System.Text.Encoding.GetEncoding("ISO-8859-15");
byte[] b = encoding.GetBytes(CSVContent);
Response.Clear();
Response.Buffer = true;
Response.AddHeader("Content-Type", "application/ms-excel");
Response.ContentType = "text/csv";
Response.AddHeader("Content-Disposition", "attachment;filename=" +
DateTime.Now.ToString("dd-MM-yyyy") + "-" + QueryName + ".txt");
Response.BinaryWrite(b);
Response.End();
}
can somebody please help me figure out how I have to modify it in
order to make it save instead of just trying to open the file?
Thank you!
Maria
I need my code to be able to generate and save an csv-file without
being prompted by a dialogue box, but I don't know if such a thing is
possible. I've found out how to generate the file without problems,
but I cannot seem to make it save the file to a predetermined
location. Is such a thing even possible?
The code I use to generate and open the file is below
private void CreateResponse(string QueryName, string CSVContent)
{
System.Text.Encoding encoding =
System.Text.Encoding.GetEncoding("ISO-8859-15");
byte[] b = encoding.GetBytes(CSVContent);
Response.Clear();
Response.Buffer = true;
Response.AddHeader("Content-Type", "application/ms-excel");
Response.ContentType = "text/csv";
Response.AddHeader("Content-Disposition", "attachment;filename=" +
DateTime.Now.ToString("dd-MM-yyyy") + "-" + QueryName + ".txt");
Response.BinaryWrite(b);
Response.End();
}
can somebody please help me figure out how I have to modify it in
order to make it save instead of just trying to open the file?
Thank you!
Maria