Gael Rodriguez Asked: 2020-07-20 13:03:46 +0800 CST 2020-07-20 13:03:46 +0800 CST 2020-07-20 13:03:46 +0800 CST Continually read text file whenever path is detected to exist c# 772 I am developing a program in which I need to read a text file every time it is saved in a path c# 1 Answers Voted Best Answer Leandro Tuttini 2020-07-20T14:51:38+08:002020-07-20T14:51:38+08:00 To monitor a folder before file events you can use the classFileSystemWatcher FileSystemWatcher Class then you define using (FileSystemWatcher watcher = new FileSystemWatcher()) { watcher.Path = @"c:\..."; //la carpeta que quiere controlar watcher.Filter = "*.txt"; watcher.Changed += OnChanged; watcher.EnableRaisingEvents = true; } assigning the event changedyou will have the event when a modification is recorded private void OnChanged(object source, FileSystemEventArgs e){ //codigo } Of course you have other events that you can use
To monitor a folder before file events you can use the class
FileSystemWatcher
FileSystemWatcher Class
then you define
assigning the event
changed
you will have the event when a modification is recordedOf course you have other events that you can use