I need to compare two files based on datetime. I need to check whether these two files were created or modified with same datetime. I have used this code to read the datetime of files…
string fileName = txtfile1.Text;
var ftime = File.GetLastWriteTime(fileName).ToString();
string fileName2 = txtfile2.Text;
var ftime2 = File.GetLastWriteTime(fileName2).ToString();
Any suggestions?
Don’t call
ToString()on theDateTimevalues returned byGetLastWriteTime(). Do this instead:Then you can just compare
ftimeandftime2: