Reputation: 21
I am using C Sharp.Net fileSystemWatcher class to watch if file renamed. Code is working fine and giving notification if file renamed but I am unable to find out old name of renamed file. I am using 'e.OldFullPath' but it's not working. I am getting error: does not contain definition for oldFullPath
My code:
private void watcher_FileRenamed(object sender, System.IO.FileSystemEventArgs e)
{
Console.WriteLine("File " + e.OldFullPath + " [Changed to] " + e.FullPath);
}
Please help me. Thanks.
Upvotes: 0
Views: 319
Reputation: 57583
Problem is because you're not changing directory, but just name.
So try to use e.OldName
for old name and e.Name
for new name and see what happens.
e.OldFullPath
is used for other operations like copying or moving.
Upvotes: 1