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. using new line in saveFileDialog

using new line in saveFileDialog

Scheduled Pinned Locked Moved C#
help
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.
  • V Offline
    V Offline
    veluru krishna
    wrote on last edited by
    #1

    hi, when use the following code SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "Text Files|*.txt|Comma Seperated Files|*.csv|All Files|*.*"; dlg.InitialDirectory = @"C:\"; saveFileDialog1.OverwritePrompt = true; if (dlg.ShowDialog() == DialogResult.OK) { using (System.IO.StreamWriter writer = new System.IO.StreamWriter(dlg.FileName)) { writer.Write(this.richTextBox1.Text); writer.Flush(); } } it saves a file but unfortunately it saves it without newline characters ie.,. I want to save my work as it is displayed in the multiline text box.can you help me please

    Don't wait to hear a word of thanks from anybody when you help them instead ask them to help three other people and ask them to continue in chain.

    L 1 Reply Last reply
    0
    • V veluru krishna

      hi, when use the following code SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "Text Files|*.txt|Comma Seperated Files|*.csv|All Files|*.*"; dlg.InitialDirectory = @"C:\"; saveFileDialog1.OverwritePrompt = true; if (dlg.ShowDialog() == DialogResult.OK) { using (System.IO.StreamWriter writer = new System.IO.StreamWriter(dlg.FileName)) { writer.Write(this.richTextBox1.Text); writer.Flush(); } } it saves a file but unfortunately it saves it without newline characters ie.,. I want to save my work as it is displayed in the multiline text box.can you help me please

      Don't wait to hear a word of thanks from anybody when you help them instead ask them to help three other people and ask them to continue in chain.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Are you viewing your file with notepad.exe? RichTextBox delimits the lines with a \n instead of the windows typical \r\n, that's why some editors have troubles with it. Proper editors like NotePad++ or UltraEdit have no problems with a \n on windows. You might do that: writer.Write(richTextBox1.Text.Replace("\n", Environment.NewLine));

      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