using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication8 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void watcherToolStripMenuItem_Click(object sender, EventArgs e) { Form2 f2 = new Form2(); f2.Show(); } private void Form1_Load(object sender, EventArgs e) { } } }
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; namespace WindowsFormsApplication8 { public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { start(); } public void start() { FileSystemWatcher fsw = new FileSystemWatcher(); fsw.Deleted += new FileSystemEventHandler(ondelete); fsw.Path = @"d:\"; WaitForChangedResult wfc = fsw.WaitForChanged(WatcherChangeTypes.All); } public void ondelete(object sender, FileSystemEventArgs e) { richTextBox1.AppendText("file deleted"); start(); //MessageBox.Show("file deleted"); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)