I've been given a task to export data into the csv file. every thing is working fine apart from the destination folder. Every time it saves csv file on windows downloads (C:\Users\xxxpurt\Downloads) folder. I want to use a desired location to save the csv file by specifying the location which I can get it from SaveFileDialog. Is this possible? If it is then how can I specify path retrieved from saveFiledialog to response? Ta
string location = string.Empty;
SaveFileDialog saveCSVDialog = new SaveFileDialog();
saveCSVDialog.InitializeLifetimeService();
saveCSVDialog.Filter = "csv files (*.csv)|*.csv|All files (*.*)|*.*";
saveCSVDialog.FilterIndex = 1;
saveCSVDialog.DefaultExt = ".csv";
saveCSVDialog.RestoreDirectory = true;
DialogResult res = STAShowDialog(saveCSVDialog); //STAShowDialog uses threading
if (res == DialogResult.OK)
{
location = saveCSVDialog.FileName;
}
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", string.Format("attachment;filename={0}", Server.HtmlEncode(location)));
Response.Charset = "";
Response.ContentType = "application/text";
.........Fetch columns and rows using loops.........
Response.Output.Write(sb.ToString());
Response.Flush();
Response.End();