Store file in particular location
-
Hi friends, I am using the following code to read a table and store the table as a text file it works fine but i want to store the text file in a specific location according to need,any function to do it?By default it is storing in desktop how to change it? StringBuilder str = new StringBuilder(); for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++) { for (int j = 0; j <= ds.Tables[0].Columns.Count - 1; j++) { str.Append(ds.Tables[0].Rows[i][j].ToString()); } str.Append(Environment.NewLine); } Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=FileName.m3u"); Response.Charset = ""; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = "application/vnd.txt"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); Response.Write(str.ToString()); Response.End();
-
Hi friends, I am using the following code to read a table and store the table as a text file it works fine but i want to store the text file in a specific location according to need,any function to do it?By default it is storing in desktop how to change it? StringBuilder str = new StringBuilder(); for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++) { for (int j = 0; j <= ds.Tables[0].Columns.Count - 1; j++) { str.Append(ds.Tables[0].Rows[i][j].ToString()); } str.Append(Environment.NewLine); } Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=FileName.m3u"); Response.Charset = ""; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = "application/vnd.txt"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); Response.Write(str.ToString()); Response.End();
B87 wrote:
By default it is storing in desktop how to change it?
That depends on user and browser. Once the file is sent to response, ASP.NET don't have any control over it.
Navaneeth How to use google | Ask smart questions