请帮我比较两个文本文件中的日期和时间,并比较以检查它们是否相同,使用DateTime.TryParse
方法或任何其他方法。
我有以下代码:
String[] file1Lines = File.ReadAllLines("Text.txt");
String[] file2Lines = File.ReadAllLines("Text2.txt");
for (int i = 0; i < Math.Max(file1Lines.Length, file2Lines.Length); i++)
{
if (i > file1Lines.Length)
/* missing from file 1 */
Console.WriteLine("Missing from File 1");
else if (i > file2Lines.Length)
/* missing from file 2); */
Console.WriteLine("Missing from File 1") ;
else if (file1Lines[i].Equals(file2Lines[i]))
/* lines are equal */
Console.WriteLine("Lines are equal") ;
else
/* lines are different */
Console.WriteLine("Lines are different");
}