监听文件夹的时候如何判断其内的文件是否完全生成?

 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 });
                }
               
            };

posted @ 2013-04-19 09:52  FiberHomer  阅读(253)  评论(0编辑  收藏  举报