using System;
using System.IO;
class Test
{
public static void Main()
{
string path = @"c:\temp\MyTest.txt";
if (!File.Exists(path))
{
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine("Hello");
sw.WriteLine("And");
sw.WriteLine("Welcome");
}
}
using (StreamReader sr = File.OpenText(path))
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
Console.WriteLine(s);
}
}
string path2 = path + "temp";
File.Delete(path2);
File.Copy(path, path2);
Console.WriteLine("{0} was copied to {1}.", path, path2);
File.Delete(path2);
Console.WriteLine("{0} was successfully deleted.", path2);
}
}