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. General Programming
  3. C#
  4. Export from textbox to external file

Export from textbox to external file

Scheduled Pinned Locked Moved C#
csharpdatabase
3 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.
  • C Offline
    C Offline
    Code Toad
    wrote on last edited by
    #1

    I am fairly new to C# and am trying to export the text from a multi-line textbox to an external file. I am familiar with SaveFileDialog when exporting the contents of a DataGrid, but am unsure as to how I would assign the textbox data. Here is what I would have done if I were exporting the data from a C1TrueDBGrid. I am sure that I am just missing something simple :) ------------------------------------------------------- protected virtual void Export() { System.Windows.Forms.SaveFileDialog saveFileDialog = new SaveFileDialog() ; saveFileDialog.Filter = "Excel |*.csv|Text|*.txt" ; saveFileDialog.InitialDirectory = @"C:\" ; saveFileDialog.OverwritePrompt = true ; saveFileDialog.FileName = "dbview_" + this.tableName.Replace(" ", ""); saveFileDialog.Title = "Database View for " + this.tableName.TrimEnd() ; saveFileDialog.ShowDialog() ; try { if (System.IO.File.Exists(saveFileDialog.FileName)) { System.IO.File.Delete(saveFileDialog.FileName) ; } this.c1TrueDBGrid1.ExportToDelimitedFile(saveFileDialog.FileName, C1.Win.C1TrueDBGrid.RowSelectorEnum.AllRows, ",", "", "", true, "ASCII") ; System.Diagnostics.Process.Start(saveFileDialog.FileName) ; } catch {} }

    G 1 Reply Last reply
    0
    • C Code Toad

      I am fairly new to C# and am trying to export the text from a multi-line textbox to an external file. I am familiar with SaveFileDialog when exporting the contents of a DataGrid, but am unsure as to how I would assign the textbox data. Here is what I would have done if I were exporting the data from a C1TrueDBGrid. I am sure that I am just missing something simple :) ------------------------------------------------------- protected virtual void Export() { System.Windows.Forms.SaveFileDialog saveFileDialog = new SaveFileDialog() ; saveFileDialog.Filter = "Excel |*.csv|Text|*.txt" ; saveFileDialog.InitialDirectory = @"C:\" ; saveFileDialog.OverwritePrompt = true ; saveFileDialog.FileName = "dbview_" + this.tableName.Replace(" ", ""); saveFileDialog.Title = "Database View for " + this.tableName.TrimEnd() ; saveFileDialog.ShowDialog() ; try { if (System.IO.File.Exists(saveFileDialog.FileName)) { System.IO.File.Delete(saveFileDialog.FileName) ; } this.c1TrueDBGrid1.ExportToDelimitedFile(saveFileDialog.FileName, C1.Win.C1TrueDBGrid.RowSelectorEnum.AllRows, ",", "", "", true, "ASCII") ; System.Diagnostics.Process.Start(saveFileDialog.FileName) ; } catch {} }

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Here is part of an example from MSDN that shows how to write text to a file: StreamWriter sr = File.CreateText(FILE_NAME); sr.WriteLine ("This is my file."); sr.WriteLine ("I can write ints {0} or floats {1}, and so on.", 1, 4.2); sr.Close(); --- b { font-weight: normal; }

      C 1 Reply Last reply
      0
      • G Guffa

        Here is part of an example from MSDN that shows how to write text to a file: StreamWriter sr = File.CreateText(FILE_NAME); sr.WriteLine ("This is my file."); sr.WriteLine ("I can write ints {0} or floats {1}, and so on.", 1, 4.2); sr.Close(); --- b { font-weight: normal; }

        C Offline
        C Offline
        Code Toad
        wrote on last edited by
        #3

        That was exactly what I needed and worked great! Thanks and have a good one!

        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