Code:
using System;
using System.IO;
class Program
{
static void Main()
{
FileInfo finfo = new FileInfo("C:\\sri\\srip.txt");
using (StreamWriter writer = finfo.AppendText())
{
writer.WriteLine("New File with various Text operations");
}
finfo = new FileInfo("C:\\sri\\srip.txt");
using (StreamWriter writer = finfo.CreateText())
{
writer.WriteLine("New File with various Text operations");
}
using (StreamReader reader = finfo.OpenText())
{
Console.WriteLine(reader.ReadToEnd());
}
Console.Read();
}
}
Output:
New File with various Text operations
More C# Programs: