File system watcher ondeleting event
-
Thursday, February 23, 2012 5:21 AMondeleting event in file system watcher
All Replies
-
Thursday, February 23, 2012 7:30 PMModerator
There is no "OnDeleting" in FileSystemWatcher.
The closest event provided is Deleted: http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.deleted.aspx
This is fired when a file is deleted from within the file system.
Do you have a specific question regarding this event?
Reed Copsey, Jr. - http://reedcopsey.com
If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".- Proposed As Answer by AdaveshMVP Friday, February 24, 2012 5:19 AM
- Marked As Answer by Lie YouModerator Thursday, March 08, 2012 3:08 AM
-
Friday, February 24, 2012 4:33 AM
Hi Anjana Prasanth,
You can read the following thread for getting more information about it:
Monitor Multiple Files using FileSystemWatcher
http://www.codeproject.com/Articles/19925/Monitor-Multiple-Files-using-FileSystemWatcher
Advanced FileSystemWatcher
http://www.codeproject.com/KB/files/AdvancedFileSystemWatcher.aspx?q=FileSystemWatcher
I hope it will solve your problem.
Sincerely,
Jason Wang
orichisonic http://blog.csdn.net/orichisonic If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
- Marked As Answer by Lie YouModerator Thursday, March 08, 2012 3:08 AM
-
Friday, February 24, 2012 5:21 AM
Anjana... FYI, please do not start a new thread as you have already asked the question here.
Please mark this post as answer if it solved your problem. Happy Programming!
-
Friday, February 24, 2012 11:44 AM
public class Watcher { public Watcher() { } public Watcher(string Path, string Filter) { FileSystemWatcher FSW = new FileSystemWatcher(Path); FSW.Created += new FileSystemEventHandler(FSW_Changed); FSW.Deleted += new FileSystemEventHandler(FSW_Changed); FSW.Renamed += new RenamedEventHandler(FSW_Renamed); if (Filter != null || Filter != "") { FSW.Filter = Filter; } FSW.IncludeSubdirectories = true; FSW.EnableRaisingEvents = true; } void FSW_Renamed(object sender, RenamedEventArgs e) { Console.WriteLine("Object - " + e.OldName + " was " + e.ChangeType.ToString().ToLower() + " to " + e.Name + "\n"); } void FSW_Changed(object sender, FileSystemEventArgs e) { Console.WriteLine("Object - " + e.Name + " " + e.ChangeType.ToString().ToLower() + "\n"); } }
static void Main(string[] args) { Watcher w = new Watcher(@"D:\test", null); Console.ReadKey(); }- Proposed As Answer by Michael Samteladze Friday, February 24, 2012 11:50 AM
- Marked As Answer by Lie YouModerator Thursday, March 08, 2012 3:08 AM

