C# how to check if file is in folder according to object of filenames
<p>I have the following method:</p>

<pre><code>public static Boolean CheckContents(string ExportDirectory, string FileName, string DspFleName, String RteFleName, string FulRteName, string EqpFleName, int CompanyId, string CompanyName)
    {

        if (DspFleName != "None")
        {

           IList&lt;string&gt; DspFle= DspFleName.Split(',');
           IList&lt;string&gt; ActualFiles = Directory.GetFiles(ExportDirectory);
            for (int i = 0; i &lt; DspFle.Count; i++)
            {
                if (DspFle[i] != ActualFiles[i])
                {
                    return false;
                }
            }
        }
        return true;
    }
}
</code></pre>

<p>Basically what this code is meant to do is get all file names from the DspFle field which is seperated by a ,. So this would look like so:</p>

<pre><code>test.txt,test2.csv
</code></pre>

<p>Then it is getting the acutal files in the directory that is specified from 'ExportDirectory' and returns those into an IList</p>

<p>I am having 2 problems here:
1.The Directory.GetFiles returns the whole file path so that will always return false. I also tried Path.GetFileNames and this only returns the file name but it does not return the extension.</p>

<p>2.I need to compare my entire DspFle to my ActualFile IList as the file names could be in different parts of the list.</p>

<p>Any ideas?</p>
