It doesn’t get any simpler than this. In production code always make sure that you handle exceptions.
using System.IO;
....
// filePath has the complete path to the file
StreamWriter writer = new StreamWriter(filePath);
writer.Write(fileNewText);
writer.Close();
Share with