- My requirement
I am creating one desktop application , I need a network path file information which raname and create ,for that I use FileSystemWatcher it's provide Created,Renamed,changes and deleted event
- My problem
FileSystemWatcher rename event not firing for subdirectory network path,
I already set watcher.IncludeSubdirectories = true
, but it not work for rename
public void Setup() {
var watcher = new FileSystemWatcher{
Path = "My network path",
NotifyFilter = NotifyFilters.FileName | NotifyFilters.Attributes | NotifyFilters.LastWrite | NotifyFilters.Security, Filter = "*"
};
watcher.Created += OnCreated;
watcher.Renamed += OnRenamed;
// uncomment out line below to add the error handler
watcher.Error += OnError;
watcher.IncludeSubdirectories = true;
watcher.EnableRaisingEvents = true;
}
public static void OnRenamed(object source, RenamedEventArgs e)
{
try
{
MessageBox.Show("Raname call");
}
catch (Exception Ex)
{
errorLog(Ex);
}
}
public static void OnCreated(object source, FileSystemEventArgs e)
{
try
{
MessageBox.Show("OnCreated call");
}
catch (Exception Ex)
{
errorLog(Ex);
}
}