-
AppendAllLines() function in .Net framework 3.5 or similar
over 9 years ago
-
over 9 years ago
Hi Mayank,
You can't use File.AppendAllLines() function in version prior to .NET 4.0. It only works in version 4.0 & above.
Instead what you can do is create a custom AppendAllLines() function easily to solve your problem. In the following sample code we are iterating through each line and appending them one by one to the file specified using "filePath" variable.
Example:
//Function definition public static void AppendAllLines(string filePath, IEnumerable<string> inputLines) { using (var writer = new StreamWriter(filePath, true)) foreach (var line in inputLines) writer.WriteLine(line); }
1 Answer(s)