Example #1
0
        private FileSystemWatcher InitializeFileSystemWatcher(FolderObj newFolder)
        {
            FileSystemWatcher newFileSystemWatcher = new FileSystemWatcher
            {
                Path         = newFolder.Path,
                Filter       = "*.*",
                NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.CreationTime
            };

            newFileSystemWatcher.Created += new FileSystemEventHandler(NewFileWatcher_Handler);
            newFileSystemWatcher.Changed += new FileSystemEventHandler(NewFileWatcher_Handler);
            newFileSystemWatcher.Renamed += NewFileWatcher_Handler;

            newFileSystemWatcher.EnableRaisingEvents = true;

            return(newFileSystemWatcher);
        }
Example #2
0
        private void AddFolderBtn_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                Forms.FolderBrowserDialog fbd = new Forms.FolderBrowserDialog();

                fbd.ShowDialog();

                FolderObj newfolder = new FolderObj(fbd);

                _trackingFolderList.AddFolder(newfolder);

                _listOfFileSystemWatchers.Add(InitializeFileSystemWatcher(newfolder));

                FolderListView.Items.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }