Aditya Chauhan

Aditya Chauhan

  • NA
  • 102
  • 57.2k

How can we use AppendAllLines in .net framework 3.5

May 19 2015 1:32 AM
AppendAllLines is work in .net framework 4.5
but how can we use append all line in 3.5

//4.5
string[] a = new string[] { fa + " "+ lastModified };
System.IO.File.AppendAllLines(filepath, a);

//3.5
string[] a = new string[] { fa + " "+ lastModified };
var ab = string.Join(Environment.NewLine, DataList.Select(x => x.blah blah blah).ToArray());
string outputFilePath = @"C:\output.txt";
File.AppendAllText(outputFilePath, ab);

public static void AppendAllLines(string path, IEnumerable<string> lines)
{
using (var writer = new StreamWriter(path, true))
foreach (var line in lines)
writer.WriteLine(line);
}

Answers (2)