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. Windows Forms
  4. Accepting user input and writing it to a text file

Accepting user input and writing it to a text file

Scheduled Pinned Locked Moved Windows Forms
csharphelp
4 Posts 4 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi friends, I've a textbox and a button in my WinForm. Now, I want that, whatever the user enters in the textbox and clicks on the button, the entered text should be copied to a precreated text file "C:\test.txt". Note, that I am using Visual C# for this purpose. I searched google and MSDN, but my search ended up in futile. Please help me out with the appropriate code. Hope to hear from you guys soon, Rajdeep.NET :)

    D J B 3 Replies Last reply
    0
    • L Lost User

      Hi friends, I've a textbox and a button in my WinForm. Now, I want that, whatever the user enters in the textbox and clicks on the button, the entered text should be copied to a precreated text file "C:\test.txt". Note, that I am using Visual C# for this purpose. I searched google and MSDN, but my search ended up in futile. Please help me out with the appropriate code. Hope to hear from you guys soon, Rajdeep.NET :)

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      You're joking, right? You couldn't find a result for "how do I append text to a file in C#[^]"?? I guarantee you'll find tons of results with that search.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008

      1 Reply Last reply
      0
      • L Lost User

        Hi friends, I've a textbox and a button in my WinForm. Now, I want that, whatever the user enters in the textbox and clicks on the button, the entered text should be copied to a precreated text file "C:\test.txt". Note, that I am using Visual C# for this purpose. I searched google and MSDN, but my search ended up in futile. Please help me out with the appropriate code. Hope to hear from you guys soon, Rajdeep.NET :)

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

        Well I can give you simple idea. I provide you source code you need to modify it. I am having some problem with my computer else I will do that proper code for you . just post you some my old exercise . just put this function on the button click I mean where you want it will save . If you want to save automaticaly you just modify . private void savingtext() { SaveFileDialog savetx = new SaveFileDialog(); savetx.DefaultExt = "rtf"; savetx.Filter = "Texto enrriquecido (*.rtf)|*.rtf"; savetx.FileName = "Log.rtf"; if (savetx.ShowDialog() == Windows.Forms.DialogResult.OK) { textbox1.text.SaveFile(savetx.FileName); } } Wisht it will help you

        1 Reply Last reply
        0
        • L Lost User

          Hi friends, I've a textbox and a button in my WinForm. Now, I want that, whatever the user enters in the textbox and clicks on the button, the entered text should be copied to a precreated text file "C:\test.txt". Note, that I am using Visual C# for this purpose. I searched google and MSDN, but my search ended up in futile. Please help me out with the appropriate code. Hope to hear from you guys soon, Rajdeep.NET :)

          B Offline
          B Offline
          Baeltazor
          wrote on last edited by
          #4

          I'm sorry, but I just cannot believe how many people have asked the same question on so many different forums. There ARE MANY SOLUTIONS to your problem at hand that can be obtained from a Google search. And by many, I mean thousands of solutions. Here is the code. I'm only doing this because I'm in a good mood today. Any other time, you'd be ^h%t out of luck. Double-click on your button that you've added to the form and inside the event handler type:

          File.AppendAllText(@"C:\Test.txt", textBox1.Text);

          ..That is ofcourse, assuming your TextBox control's design name is still textBox1. Now, for this to work you need to include a 'using directive' in the top of your file like so:

          using System.IO;

          Hope this helps. Jason.

          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