Have you ever wanted trick your friends into believing that you created a Text File the day after you were born? When you tell them that you created a Text File the day after you were born, they are probably thinking that you are just kidding, until you show them the File's Creation, Last Accessed, and Last Written Date. You should title the File something like MyFirstTextFile.txt
Now for the Code and Explanation.
What this code does is it changes the File's Creation, Last Accessed, and Last Written Date to the Date you specify. Your friends won't believe you, but for some odd reason, they will.
Enjoy!
Now for the Code and Explanation.
What this code does is it changes the File's Creation, Last Accessed, and Last Written Date to the Date you specify. Your friends won't believe you, but for some odd reason, they will.
private void changeFileDate(String filename, DateTime newDate)
{
//Try to change the Creation Time
try
{
//Here we are setting the Creation Time to the
//specified date called newDate, for the file
//called filename
System.IO.File.SetCreationTime(filename, newDate);
}
catch
{
MessageBox.Show("There seems to be an error with the specified FileName or the specified Date.", "Error");
}
//Try to change the Last Write Time to our CreationTime
try
{
//Here we are setting the Last Write Time to the Creation Date
System.IO.File.SetLastWriteTime(filename, newDate);
}
catch
{
MessageBox.Show("There seems to be an error with the specified FileName or the specified Date.", "Error");
}
//Try to change the Last Accessed Time to our CreationTime and to our LastWriteTime
try
{
//Here we are setting the Last Accessed Time to the Creation Date and the Last Write Time
System.IO.File.SetLastAccessTime(filename, newDate);
}
catch
{
MessageBox.Show("There seems to be an error with the specified FileName or the specified Date.", "Error");
}
}
Enjoy!
0 Comments On This Entry
Search My Blog
Tags
My Blog Links
Recent Entries
-
-
-
-
-
Change File's Creation Dateon Aug 25 2008 05:51 PM
Recent Comments
0 user(s) viewing
0 Guests
0 member(s)
0 anonymous member(s)
0 member(s)
0 anonymous member(s)
|
|



Leave Comment










|