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. How to save textBox to a file

How to save textBox to a file

Scheduled Pinned Locked Moved C#
tutorialquestion
4 Posts 3 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.
  • T Offline
    T Offline
    tamir901
    wrote on last edited by
    #1

    Hi, I'm trying to save the context that i have in my textBox (Multi Line) to a text file, But to keep the lines order. i know how to do it with richTextBox- foreach (string line in richTextBox.Lines) { textToSave.WriteLine(line); } But i have to user textBox only... :( Someone has a idea?

    D J 2 Replies Last reply
    0
    • T tamir901

      Hi, I'm trying to save the context that i have in my textBox (Multi Line) to a text file, But to keep the lines order. i know how to do it with richTextBox- foreach (string line in richTextBox.Lines) { textToSave.WriteLine(line); } But i have to user textBox only... :( Someone has a idea?

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      You can make use of File.WriteAllLines method to do this.

      50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

      1 Reply Last reply
      0
      • T tamir901

        Hi, I'm trying to save the context that i have in my textBox (Multi Line) to a text file, But to keep the lines order. i know how to do it with richTextBox- foreach (string line in richTextBox.Lines) { textToSave.WriteLine(line); } But i have to user textBox only... :( Someone has a idea?

        J Offline
        J Offline
        JoeSharp
        wrote on last edited by
        #3

        hi why you write the text line by line? using(StreamWriter sw = new StreamWriter(filename)) { sw.Write(textbox.Text); } regards

        T 1 Reply Last reply
        0
        • J JoeSharp

          hi why you write the text line by line? using(StreamWriter sw = new StreamWriter(filename)) { sw.Write(textbox.Text); } regards

          T Offline
          T Offline
          tamir901
          wrote on last edited by
          #4

          Thanks, It's working great... ;)

          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