Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Store file in particular location

Store file in particular location

Scheduled Pinned Locked Moved ASP.NET
designtutorialquestionworkspace
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    B87
    wrote on last edited by
    #1

    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();

    N 1 Reply Last reply
    0
    • B B87

      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();

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups