1
在下面的代码中,test.txt在运行之前存在,而test2.txt不存在。当文件复制到destFile的位置后,运行destFile.Exists时返回null。这是什么造成的?我无法在msdn中找到任何支持正在发生的事情的信息。FileInfo.Exists在复制文件后返回False
var origFile = new FileInfo(@"C:\Users\user\Desktop\CopyTest\test.txt");
var destFile = new FileInfo(@"C:\Users\user\Desktop\CopyTest\test2.txt");
if (!destFile.Exists && origFile.Exists)
origFile.CopyTo(destFile.FullName);
if (destFile.Exists)
Console.WriteLine("The file was found");
Console.ReadLine();