To send bulk email in my web application I am using filewatcher to send the application.
I have planned to write filewatcher with the console application instead of windows service or scheduler.
I have copied the executable file shortcut in the following path.
%appdata%\Microsoft\Windows\Start Menu\Programs
Ref: https://superuser.com/questions/948088/how-to-add-exe-to-start-menu-in-windows-10
After run the executable file the file watcher is not watched always. After searching some sites, i have found that we need to add the code
new System.Threading.AutoResetEvent(false).WaitOne();
Is this the right method to add in the executable file and to watch the folder?
After run the console application (without above code) is the file won't be watched always?
What will be the right method to use the file watcher?
FileSystemWatcher watcher = new FileSystemWatcher();
string filePath = ConfigurationManager.AppSettings["documentPath"];
watcher.Path = filePath;
watcher.EnableRaisingEvents = true;
watcher.NotifyFilter = NotifyFilters.FileName;
watcher.Filter = "*.*";
watcher.Created += new FileSystemEventHandler(OnChanged);
MAIN
method after started watching? – Protectingroot
, not the file are in the insub-folders
. – Protecting