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

I am generating a word file from my http context .

And the file downloads after created, but i want it to save on the project folder using server.mappath to the folder on the server.

This is my Code : This pops up a window to download file.
HTML
StringBuilder strHTMLContent = new StringBuilder();
            strHTMLContent.Append(body);             
            HttpContext.Current.Response.Write(strHTMLContent);
            HttpContext.Current.Response.End();
            HttpContext.Current.Response.Flush();

But i want to save the file to the location path specified below
C#
var path = System.IO.Path.Combine(HttpContext.Current.Server.MapPath("~/upload/AbstractFiles"), strFileName);

Please help me How to do this.

Thank you ..
Posted
Updated 14-Mar-12 20:48pm
v2
Comments
ZurdoDev 15-Mar-12 8:03am    
The Response object is what is sent back to the client so if you are putting the file into the Response Object the client will get to choose where to save it. If you want to save on the server use the File object and save directly to the File object instead of using the Response object.
yellaleparam 5-Apr-13 17:15pm    
Hello,


Can you pls share the sample code to save the file?
ZurdoDev 8-Apr-13 7:41am    
You mean on the server?
Tipen 12-Apr-17 1:05am    
This is clear question. He want save into the path. You still asking.
yellaleparam 5-Apr-13 17:13pm    
How can I save the xls file on perticular location automatically.n can someone please suggest me? Thanks in advance.

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