title: How to compare between two directories and get the missing files? c# winform
body: <p>Thats the code :</p>
  
  <pre><code>enter code here 
  
  private void button1_Click(object sender, EventArgs e)
      {
          try
          {
              string[] Folder1 = Directory.GetFiles(txtFolder1.Text, comboBox1.SelectedItem.ToString());
              string[] Folder1FileNames = new string[Folder1.Length];
              int c = 0;
              string fname1;
  
  
              foreach (string f in Folder1)
              {
                  fname1 = Path.GetFileName(f);
                  Folder1FileNames[c] = fname1;
  
                  c++;
              }
  
  
  
              string fname2;
              string[] Folder2 = Directory.GetFiles(txtFolder2.Text, comboBox1.SelectedItem.ToString());
              string[] Folder2FileNames = new string[Folder2.Length];
              int t = 0;
              foreach (string f in Folder2)
              {
                  fname2 = Path.GetFileName(f);
                  Folder2FileNames[t] = fname2;
                  t++;
  
              }
              int m=0;
              foreach (string f in Folder1FileNames)
              {
                  while (f != Folder2FileNames[m] &amp;&amp; m &lt; Folder2FileNames.Length)
                  {
                      m++;
                      if (m == Folder2FileNames.Length)
                      {
                          Label newlabe = new Label();
                          newlabe.Text = f;
                          if(!listBox1.Items.Contains(newlabe.Text))
                          {
                              listBox1.Items.Add(newlabe.Text);
  
                          }
                      }
                  }
                  m = 0;
              }
  
  
  
          }
          catch (Exception ex)
          {
              label1.Text = ex.Message;
          }
  </code></pre>
  
  <p>I created two arrays that contains Files From SourceDirectory(Folder1) and CompareDirectory(Folder2)  , then more 2 arrays that contains the files name with out the full ptah (in order to compare between the araays) ,then i have tried to compare between the arrays ,and add the missing file to the list box .
  the problem is that when I tried it it gave me the first missing file from the source folder , (e.g source folder contains the next files  : a.txt,b.txt,c.txt,d.txt and compare folder contains:a.txt,b.txt , the result in the list box will be c.txt , and the label will show:"you are out of the array index" )
  what should i do ?
  thanks!</p>