public void TestFS_TestFileFilter() { string file = Path.Combine(dir, "1.txt"); FileStream fs = new FileStream(file, FileMode.CreateNew); fs.WriteByte(1); Assert.IsFalse(CfgPath.NeedSkip(file));//現在不再檢查該文件是否 fs.Close(); Assert.IsFalse(CfgPath.NeedSkip(file)); }
//由于文件变更通知是在一个后台线程中进行的,所以需要通过Invoke机制调用UI主线程中的函数 private void AddFileToDB_BackThread(string uri) { if (!CfgPath.NeedSkip(uri))//过滤一些不需要观察的文件 { this.Dispatcher.Invoke(new Action <string>(AddFileToDB_UIThread), uri); } else { this.Dispatcher.Invoke(new Action(NotifyList));//有一个bug,当ie保存一个文件时,总是先create,然后delete,然后再次create。 } }
private static void AssertFilter(bool r, string s) { Assert.AreEqual(r, CfgPath.NeedSkip(s)); }