private void folderBrowseButton_Click(object sender, EventArgs e) { if (monitor == null || MessageBox .Show( "при выборе новой папки для мониторинга, " + "вы потеряете текущую историю мониторинга. продолжить?", "выбор папки", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { if (monitor != null && startButton.Text == "стоп") { PushButton(); } string path = folderBrowserDialog1.SelectedPath; folderSelected = true; try { monitor = new FSMonitor(path); monitor.Changed += Monitor_Changed; monitor.Error += Monitor_Error; logRichTextBox.Text = ""; } catch (Exception ex) { MessageBox.Show(ex.Message); return; } toolStripStatusLabel2.Text = path; } } }
/// <summary> /// Create a new event arguments from the specified information. /// </summary> /// <param name="inf"></param> /// <param name="wnd"></param> /// <returns></returns> /// <remarks></remarks> internal static FSMonitorEventArgs FromPtr(FILE_NOTIFY_INFORMATION inf, FSMonitor wnd) { var fsm = new FSMonitorEventArgs(); fsm._Info = new FileNotifyInfo(inf); fsm._sender = wnd; fsm._Storage = wnd.Storage; return(fsm); }
internal void CreateMonitor() { if (_FSMon is object) { if (_FSMon.IsWatching) { var res = MessageBox.Show("You are currently watching a folder. Do you want to stop and select another?", "Watch Folder", MessageBoxButton.YesNo, MessageBoxImage.Question); if (res == MessageBoxResult.No) { return; } else { _FSMon.StopWatching(); } } } _FSMon = null; var ip = new WindowInteropHelper(this); var fb = new System.Windows.Forms.FolderBrowserDialog(); if (MonitoredFolder is null) { fb.SelectedPath = System.IO.Directory.GetCurrentDirectory(); } else { fb.SelectedPath = MonitoredFolder; } if (fb.ShowDialog() == System.Windows.Forms.DialogResult.OK) { MonitoredFolder = fb.SelectedPath; _FSMon = new FSMonitor(MonitoredFolder, ip.EnsureHandle()); } }
internal FSMonitorEventArgs(FSMonitor sender, string stor, FILE_NOTIFY_INFORMATION n, FileActions a) { _sender = sender; _Storage = stor; }
public void SetUp() { watcher = new FakeWatcher(); directory = new FakeDirectory(); SUT = new FSMonitor("", watcher, directory); }