Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GetLastWriteTime returning 12/31/1600 7:00:00 PM

I am using the following code to write the Date Modified time of a Directory to a label

string selectedPath = comboBox1.SelectedItem.ToString();
DateTime lastdate = Directory.GetLastWriteTime(selectedPath);
datemodified.Text = lastdate.ToString();

It returns the date 12/31/1600 7:00:00 PM which I have no clue where it is getting that date from. Can anyone help me understand why it is returning that date and how I can fix it? I'm using .NET 3.5

like image 831
heinst Avatar asked May 14 '12 13:05

heinst


1 Answers

From the documentation:

If the directory described in the path parameter does not exist, this method returns 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC), adjusted to local time.

So presumably your time zone is UTC-5 (in January), and the directory doesn't exist...

like image 52
Jon Skeet Avatar answered Oct 18 '22 02:10

Jon Skeet