Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3335432
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:01:03+00:00 2026-05-18T00:01:03+00:00

I am looking for a way to write to a text file in C#.

  • 0

I am looking for a way to write to a text file in C#.
I have created a form that has a textbox for firstname, lastname, phone number, date of birth.
When a user hits the button I would like that info wrote out to a text file. The examples I have found don’t really tell me how. So that’s why I am asking on here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T00:01:04+00:00Added an answer on May 18, 2026 at 12:01 am

    The very simplest way is just to use File.WriteAllText. Build the text into a single string however you want to, then use

    File.WriteAllText(filename, text);
    

    Alternatively you can open a TextWriter on the file to do it bit by bit:

    using (TextWriter writer = File.CreateText(filename)) // Or AppendText
    {
        writer.WriteLine("First name: {0}", firstNameInput.Text);
        writer.WriteLine("Last name: {0}", lastNameInput.Text);
        writer.WriteLine("Phone number: {0}", phoneInput.Text);
        writer.WriteLine("Date of birth: {0}", birthInput.Text);
    }
    

    Note that you may want to be more cunning about the date of birth than just dumping the text directly from the user – you may want to validate it and write it in a standard format, for example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm supposed to write code which when given a text file (source code) as
I'm looking for a simple way to draw 3D text on QGLWidget without using
I often have the following scenario: in order to reproduce a bug for reporting,
I am evaluating hundreds of thousands of html files. I am looking for particular
I'm building a site that requires multiple forms for the same model in varying
I'm looking for suggestions for ways to share Android app data between phones running
If you are talking about btrees, I wouldn't imagine that the additional overhead of
I am looking to add a black label with a transparent background to my
INITIAL NOTE: This is just for a personal tinkering project; I'm not writing enterprise
I am trying to figure out how to go about creating dynamic checkboxes on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.