Code:
using System;
using System.IO;
using System.Text;
class Test
{
public static void Main()
{
string textpath = @"c:\sri\test.txt";
using (FileStream fs = File.Create(textpath))
{
Byte[] info = new UTF8Encoding(true).GetBytes("File is Created");
fs.Write(info, 0, info.Length);
}
using (StreamReader sr = File.OpenText(textpath))
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
Console.WriteLine(s);
}
}
Console.Read();
}
}
Output:
File is Created
More C# Programs: