I need monitor a folder, see if a file or files has been uploaded. And then I need to get the created date & time of the latest file that has been uploaded and see whether the time creation of the file has been more than 30 minutes from the current time. I have used the FileSystemWatcher to monitor the folder but how should I proceed for finding and comparing the latest file with current time.
private void watch()
{
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = path;
watcher.NotifyFilter = NotifyFilters.LastWrite;
NotifyFilters.DirectoryName;
watcher.Filter = "*.*";
watcher.Changed += new FileSystemEventHandler(OnChanged);
watcher.EnableRaisingEvents = true;
}
Private void OnChanged(object source, FileSystemEventArgs e)
{
//Copies file to another directory.
}
How shall I do that in c#. Please help!