void FileWatcher_FileModified(object sender, string fileName) { if (MainWindow.InvokeRequired && MainWindow.IsHandleCreated && !MainWindow.IsDisposed) { MainWindow.BeginInvoke(new FileModifiedEventHandler(FileWatcher_FileModified), new object[] { sender, fileName }); } else { Document doc = FindOpenDocument(fileName); if (doc != null) { doc.OnExternallyModified(); } } }
void FileWatcher_FileAttributesChanged(object sender, string fileName, FileAttributes oldAttr, FileAttributes newAttr) { if (MainWindow.InvokeRequired && MainWindow.IsHandleCreated && !MainWindow.IsDisposed) { MainWindow.BeginInvoke(new FileAttributesChangedEventHandler(FileWatcher_FileAttributesChanged), new object[] { sender, fileName, oldAttr, newAttr }); } else { Document doc = FindOpenDocument(fileName); if (doc != null && File.Exists(fileName)) { try { FileAttributes attr = File.GetAttributes(fileName); doc.ReadOnly = (attr & FileAttributes.ReadOnly) != 0; } catch (Exception) { } } } }