string attachment = "attachment; filename=Myfile.csv";
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.AddHeader("content-disposition", attachment);
HttpContext.Current.Response.ContentType = "text/csv";
HttpContext.Current.Response.AddHeader("Pragma", "public");
// My logic goes here to write file.
// Now I want to copy above file to another file.
string filepath = Server.MapPath("~/ExportedFiles/") +"Newfile.csv";
var ExcelFile = File.Create(filepath);
ExcelFile.Close();
HttpContext.Current.Response.TransmitFile(filepath);
HttpContext.Current.Response.Flush();
The above code is not working, please suggest me. Thanks.