Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello Sir
I am downloading a .csv file using following code but it's convert into XML Document (.xml)
when i set it's ContentType to msexcel it get my data in single column


C#
Response.ClearHeaders();
        Response.ClearContent();
        Response.ContentType = Path.GetExtension(Path.GetFileName(path));
        Response.AddHeader("content-disposition", "attachment; filename=" + path);
        Response.WriteFile(path);


so plz tell me i have to use to download csv file
thank you
Posted

1 solution

try to use this code:

C#
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = "text/csv";
Response.AddHeader("content-disposition", "attachment; filename=" + Path.GetFileName(path));
Response.WriteFile(path)
 
Share this answer
 
Comments
dkgawriya21 14-Feb-12 1:33am    
thank You
Michael dg 14-Feb-12 2:05am    
you are welcome!

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