title: Use FileSystemWatcher in ASP.net
body: <p>I have created File system watcher for console application. it is working flawless.</p>
  
  <p>unliess you press 'q' its keep listning the folder for adding files and display name of the files when found.</p>
  
  <pre><code>public void FileWatcher()
          {
              while (true)
              {
  
                  FileSystemWatcher watcher = new FileSystemWatcher();
                  watcher.Path = @"C:\\WATCH-FOLDER";
                  watcher.IncludeSubdirectories = true;
  
                  watcher.NotifyFilter = NotifyFilters.Attributes |
                  NotifyFilters.CreationTime |
                  NotifyFilters.DirectoryName |
                  NotifyFilters.FileName |
                  NotifyFilters.LastAccess |
                  NotifyFilters.LastWrite |
                  NotifyFilters.Security |
                  NotifyFilters.Size;
  
                  watcher.Filter = "*.*";
  
                  watcher.Changed += new FileSystemEventHandler(OnChanged);
                  watcher.Created += new FileSystemEventHandler(OnChanged);
  
                  watcher.EnableRaisingEvents = true;
              }
  
          }
  
          public void OnChanged(object source, FileSystemEventArgs e)
          {
              Console.WriteLine("{0}, with path {1} has been {2}", e.Name, e.FullPath, e.ChangeType);
          }
  
          public void OnRenamed(object source, RenamedEventArgs e)
          {
  
              Console.WriteLine(" {0} renamed to {1}", e.OldFullPath, e.FullPath);
          }
  </code></pre>
  
  <p>but now how can i use this in my web application. what i want, when ever file adds in folder it picked and and insert info in database. so when i press show all so this info would be part of existing data in table.</p>
  
  <p>But i have no idea where to put function. Some people says put it in Global.asax file, and some says put in main page, or add thread. I am completly confused and have no idea how to do that. </p>