Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have code in which I have to convert elements of div into multiple csv file at a time. Now what I want is that all the files should be saved at a predefined location from code. I don't want download option to save these files e.g. if there are 10 files then they should be save in a predefined drive like C:\temp\folder.


How to implement this?


Thanks in Advance
Posted
Updated 1-Sep-14 19:05pm
v2
Comments
saxenaabhi6 2-Sep-14 1:41am    
If you mean you want to save a csv file at clients pc at c:\temp\folder by skipping that download save as popup. Then sorry, you cant do that, it is a browser requirement and your code has no control over it.

1 solution

follow below code here i have saved my csv file C:\ drive,

strcontent is the content which you want to save in csv file


try
{
    Response.Clear();
    Response.AddHeader("Content-Disposition", "attachment; filename=Report.csv");
    Response.ContentType = "application/octet-stream";
    Response.Write(strContent);
    Response.End();
}
catch (System.Threading.ThreadAbortException ex)
{
    StreamWriter sw = new StreamWriter(@"c:/Report.csv");
    sw.Write(strContent);
    sw.Close();

    System.IO.FileInfo fileInfo = new FileInfo(@"c:/");
    fileInfo.Delete();
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900