using System;
using System.IO;
using System.Text;
class Test
{
public static void Main()
{
string filePath = @"c:\temp\MyTest.txt";
if (File.Exists(filePath))
{
File.Delete(filePath);
}
using (FileStream fs = File.Create(filePath))
{
Byte[] info = new UTF8Encoding(true).GetBytes("This is some text in the file.");
fs.Write(info, 0, info.Length);
}
using (FileStream fs = File.Open(filePath, FileMode.Open, FileAccess.Read))
{
byte[] b = new byte[1024];
UTF8Encoding temp = new UTF8Encoding(true);
while (fs.Read(b,0,b.Length) > 0)
{
Console.WriteLine(temp.GetString(b));
}
fs.Write(b,0,b.Length);
}
}
}