title: FilesSystemWatcher For each item in List, look at that file
body: <p><strong>Goal:</strong></p>
  <p>The main goal is to get all path names from MySQL, and use File System Watch to watch them paths for rename, deleted and created.</p>
  <p>I have this full code here:</p>
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.IO;
  using MySql.Data.MySqlClient;
  
  namespace ConsoleApp1
     
  {
      class Program
      {
  
  
          static void Main(string[] args)
          {
  
              Run();
          }
  
          public static void Run()
          {
  
              MySqlConnection mcon = new MySqlConnection(&quot;credentials&quot;);
              MySqlDataReader myreader = null;
              MySqlCommand cmd = new MySqlCommand(&quot;select * from files&quot;, mcon);
              mcon.Open();
  
              myreader = cmd.ExecuteReader();
  
              List&lt;String&gt; list = new List&lt;String&gt;();
              while (myreader.Read())
              {
                  list.Add(myreader[1].ToString());
  
                  foreach (string i in list)
                  {
                      Console.WriteLine(i);
                      FileSystemWatcher watcher = new FileSystemWatcher();
                      watcher.Path = Path.GetDirectoryName($@&quot;{i}&quot;);
                      watcher.Filter = Path.GetFileName($@&quot;{i}&quot;);
                      watcher.EnableRaisingEvents = true;
                      watcher.IncludeSubdirectories = true;
  
                      watcher.Created += directoryChange;
                      watcher.Deleted += directoryChange;
                      watcher.Renamed += onRename;
  
                      Console.Read();
                  }
              }
              mcon.Close();
  
  
          }   
  
  
          private static void directoryChange(object source, System.IO.FileSystemEventArgs e)
          {
              Console.WriteLine($&quot;{e.ChangeType} - {e.FullPath} - {System.Environment.NewLine}&quot;);
          }
  
          private static void onRename(object source, RenamedEventArgs e)
          {
              Console.WriteLine($&quot;{e.OldFullPath} renamed to {e.FullPath}&quot;);
          }
  
  
  
      }
  }
  </code></pre>
  <p>And this is a table in MySQL:</p>
  <pre><code>ID                   Path
  1   G:/Folder/EdGzi/Test purposes Python/file.txt
  2   G:/Folder/EdGzi/Test purposes Python/test2.txt
  </code></pre>
  <p><strong>Problem:</strong></p>
  <p>When I run this application. It watches only 1 file(only the top record only from MySQL data). Whereas, it should have been watching all the files returned from MySQL table.</p>
  <p>That's why I have created the <code>foreach</code> code.</p>
  <h3>Question:</h3>
  <p>How can I do this?</p>