c# txt file to list code example
Example 1: c# read text file to list string
List<string> lines = System.IO.File.ReadLines(completePath).ToList();
Example 2: List string to file C#
string[] lines = { "First line", "Second line", "Third line" };
System.IO.File.WriteAllLines(@"C:\Users\Public\TestFolder\WriteLines.txt", lines);
lines = { "Fourth line", "Fith line" };
System.IO.File.AppendAllLines(@"C:\Users\Public\TestFolder\WriteLines.txt", lines);