I would like to know how I can get the list of newly created files during an application instance in a certain directory when my application was open.
Just to be clear: Every time my application is opened, few files get generated in a certain directory, I want the list of only those files which got created after the application was opened.
Use FileWatcher
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = @"C:\temp";
watcher.NotifyFilter = NotifyFilters.FileName;
watcher.Filter = "*.*";
watcher.Created += new FileSystemEventHandler(OnCreated);
watcher.EnableRaisingEvents = true;
private static void OnCreated(object sender, FileSystemEventArgs e)
{
Console.WriteLine($"File created {e.Name}");
}