Hi Everyone,
I am new to this forum and this is my first post. Something fascinates me about learning a language and I thought I give it a try.
Anyway I want to start with something simple but I can't figure out how to append user input to external file.
This is what I have so far. I can output to screen but do not know how to output to an existing file. Also how do I include a comma to seperate the first and last name.
My text file read as follow.
----------
John,Smith
Tom, Reed
----------
Thank You.
Trianne
I am new to this forum and this is my first post. Something fascinates me about learning a language and I thought I give it a try.
Anyway I want to start with something simple but I can't figure out how to append user input to external file.
This is what I have so far. I can output to screen but do not know how to output to an existing file. Also how do I include a comma to seperate the first and last name.
namespace test { class Program { static void Main(string[] args) { string filePath = @"C:\C#\Projects\test.txt"; File.ReadAllLines(filePath); Console.Write("Please enter your first name? "); string FirstName = Console.ReadLine(); Console.Write("Please enter your last name? "); string LastName = Console.ReadLine(); Console.Write(FirstName + " " +LastName); Console.ReadLine(); } } }
My text file read as follow.
----------
John,Smith
Tom, Reed
----------
Thank You.
Trianne
Last edited by a moderator: