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

  • SEARCH
  • Home
  • 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 have some text that is in a file. I want to encrypt this
I'm looking for way to write Javascript programs / scripts on desktop, not inside
What I'm looking for is a way to write out a python Fraction() type
My problem is that I was looking for way to use both storyboard and
Looking for a way to get path of file (and then process it in
I'm looking for a portable way (application, file format, library/API, CMS, DBMS, whatever) to
I have a textarea on my page where i allow users to write text.
I'm currently looking for a way to write to the beginning and end of
Im looking for a way of running a Twitter Search (Automated via CRON) that
I'm looking for the simplest way to pass an xml file as a store

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.