私は C# で WPF アプリケーションを作成していますが、いくつかのファイルを移動する必要があります。これを行うために、移動後にファイルがターゲット ディレクトリに到達することを確認するチェックを作成しました。問題は、ファイルの移動が完了する前にチェックに到達することがあるということです。
System.IO.File.Move(file.FullName, endLocationWithFile);
System.IO.FileInfo[] filesInDirectory = endLocation.GetFiles();
foreach (System.IO.FileInfo temp in filesInDirectory)
{
if (temp.Name == shortFileName)
{
return true;
}
}
// The file we sent over has not gotten to the correct directory....something went wrong!
throw new IOException("File did not reach destination");
}
catch (Exception e)
{
//Something went wrong, return a fail;
logger.writeErrorLog(e);
return false;
}
ファイルが実際に宛先に到達することを確認する方法を誰か教えてもらえますか? -- 移動するファイルは非常に大きい可能性があります -- (最大 2 時間のフル HD mp4 ファイル)
ありがとう!