Hi ntsol-5133,
When you save an xlsx file, it writes the data to a temporary file and then "moves" it to the final directory, which may be triggered by a "rename" event.
My test also proved this and please refer to the following code.
FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(@"C:\Users\Desktop\excle");
fileSystemWatcher.Filter = "";
fileSystemWatcher.NotifyFilter = NotifyFilters.LastWrite |
NotifyFilters.DirectoryName | NotifyFilters.FileName |
NotifyFilters.Size;
fileSystemWatcher.Renamed += new RenamedEventHandler(OnRenamed);
fileSystemWatcher.EnableRaisingEvents = true;
private static void OnRenamed(object source, RenamedEventArgs e)
{
// Specify what is done when a file is renamed.
//Console.WriteLine("File: {0} renamed to {1}", e.OldFullPath, e.FullPath);
Console.WriteLine("File:{0}", e.FullPath);
}
Best Regards,
Daniel Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.