I need to appned .txt to user input,like course and put in to the file,looks like i managed to do it ,but in second part need arraylist and insert into it subjects and then right to the text file and ouput/display. For some reason the 'exit' is diplayed too and no subjects copied into arraylist.What did i missed?
using System;
using System.Collections;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UserInput
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter new couse name - type exit and press enter to finish editing:");
string newContent = Console.ReadLine();
while (newContent != "exit")
{
File.AppendAllText("Info.txt", newContent + Environment.NewLine);
newContent = Console.ReadLine();
Console.WriteLine("Please enter new course subject - type exit and press enter to finish editing:");
string newContent1 = Console.ReadLine();
ArrayList list = new ArrayList();
list.Add(newContent1);
File.AppendAllText("Info.txt", newContent + Environment.NewLine);
newContent = Console.ReadLine();
}
string[] linesIn = System.IO.File.ReadAllLines(@"Info.txt");
// Display the file contents by using a foreach loop.
System.Console.WriteLine("Contents of Info.txt = ");
foreach (string line in linesIn)
{
// Use a tab to indent each line of the file.
Console.WriteLine("\t" + line);
}
// Keep the console window open in debug mode.
Console.WriteLine("Press any key to exit.");
System.Console.ReadKey();
}
}
}