How to end filewatcher from another method?
<p>Below is my code for a File watcher class I wrote:</p>

<pre><code>class FileWatcher  
{  
    #region Method that begins watching  
    public static void watch()  
    {

        FileSystemWatcher watcher = new FileSystemWatcher();

        watcher.Path = ConfigurationManager.AppSettings["OpticusFileLoc"];
        watcher.Filter = ConfigurationManager.AppSettings["OpticusFileName"];

        watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName;

        watcher.Changed += new FileSystemEventHandler(OnChanged);
        Console.Write("\nWatcher started. Press any key to end.\n");

        watcher.EnableRaisingEvents = true;
    }
    #endregion

    #region Trigger function on change
    public static void OnChanged(object source, FileSystemEventArgs e)
    {
        Console.WriteLine("File has been changed.\n");
        //watcher.EnableRaisingEvents = false ;

        //Program.Main();
    }
    #endregion

}
</code></pre>

<p>How can I, from the OnChanged method, set the watcher.EnableRaisingEvents flag to false?</p>

<p>I guess I could do it by moving the declaration of the FileSystemWatcher object outside the method it is in, but I'm wondering if there's another way to do it.</p>
