How to compare two folders for similar files based on name in C#?
<p>I have two folders <code>A</code> and <code>B</code>..Inside A multiple files are there and inside B multiple files are there..I have to check files in A with files in B for identical files...
I tried like this for a particular file name </p>

<pre><code>void DirSearch(string sDir)
        {
          List&lt;string&gt; lstFilesFound = new List&lt;string&gt;();
                foreach (string d in Directory.GetDirectories(sDir))
                    {
                        foreach (string f in Directory.GetFiles(d,"MsBuild_Tracker.proj")
                           {
                                lstFilesFound.Add(f);
                           }
                            DirSearch(d);
                    }
       }
</code></pre>

<p>It is working..I tried like this for two folders</p>

<pre><code>foreach (string d in Directory.GetDirectories(sDir))
                {
                    foreach (string f in Directory.GetDirectories(dDir))
                    {
                        foreach (string g in Directory.GetFiles(d, f))
                        {
                            lstFilesFound.Add(g);
                        }
                        DirSearch(d, f);
                    }
                }
</code></pre>

<p>It is not working...Any suggestion??</p>
