Tell me how to make the program constantly look through the folder, and when a file appears in it, load it, and after loading, the file is deleted.
|
2 answers
Customize tracking
private static void Track(object source, FileSystemEventArgs e) { // ... FileSystemWatcher watcher = new FileSystemWatcher(); watcher.Path = "."; watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite; watcher.Created += new FileSystemEventHandler(OnCreated); watcher.EnableRaisingEvents = true; // ... }
On the file creation event download and delete it
private static void OnCreated(object source, FileSystemEventArgs e) { // TODO: загрузить и удалить файл по имени e.FullPath }
|
Component FileSystemWatcher
to help you.
|