监听文件夹的时候如何判断其内的文件是否完全生成?
fileWatcher.Created += (s, e) =>
{
//获得改变文件
string createFileName = e.FullPath;
if (IsProvisionsSuffix(createFileName))
{
while (true)
{
StreamReader sr = null;
try
{
sr = new StreamReader(createFileName);
sr.Close();
break;
}
catch (Exception)
{
Thread.Sleep(100);
}
}
//然后进行逻辑处理
ProcessFile(new string[] { createFileName });
}
};