private void Form1_Load(object sender, EventArgs e) { FileSystemWatcher fsw = new FileSystemWatcher(); fsw.Path = @"E:\Mahbub IT\"; fsw.EnableRaisingEvents = true; fsw.Filter = "*.*"; fsw.IncludeSubdirectories = true; fsw.Created += new FileSystemEventHandler(file_handler_function); fsw.Changed += new FileSystemEventHandler(file_handler_function); fsw.Deleted += new FileSystemEventHandler(file_handler_function); fsw.Renamed += new RenamedEventHandler(file_rename_handler_function); } private void file_handler_function(object sender, FileSystemEventArgs e) { if (e.ChangeType == WatcherChangeTypes.Created) { MessageBox.Show("New file created : " + e.FullPath); } else if (e.ChangeType == WatcherChangeTypes.Deleted) { MessageBox.Show("File is deleted : " + e.FullPath); //MessageBox.Show(Request.UserHostAddress); } else if (e.ChangeType == WatcherChangeTypes.Changed) { MessageBox.Show("File modified : " + e.FullPath); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)