using System;
using System.IO;
class Test
{
public static void Main()
{
try
{
string path = @"c:\MyTest.txt";
if (!File.Exists(path))
{
File.Create(path);
}
else
{
File.SetLastWriteTime(path, new DateTime(2010,4,3));
}
DateTime dt = File.GetLastWriteTime(path);
Console.WriteLine("The last write time for this file was {0}.", dt);
File.SetLastWriteTime(path, DateTime.Now);
dt = File.GetLastWriteTime(path);
Console.WriteLine("The last write time for this file was {0}.", dt);
}
catch (Exception e)
{
Console.WriteLine("The process failed: {0}", e.ToString());
}
}
}