title: String Pattern Matching using basic String Operations
body: <p>I have a method that allows the user to specify a remote directory and a searchPattern with with to search files in the remote directory. Since I use third party libraries when retrieving the names of the files from the remote location, I am unable to take advantage of System.IO's Directory.GetFiles() routine which allows me specify the searchPattern when getting the files. </p>
  
  <p>Basic String.Compare does not properly match the filename against the supplied pattern. Anyone know a more effective way of doing the matching please? </p>
  
  <pre><code>public IList&lt;String&gt; GetMatchingRemoteFiles(String SearchPattern, bool ignoreCase)
  {
      IList&lt;String&gt; matchingFileNames = new List&lt;String&gt;();
  
     var RemoteFiles = thirdPartyTool.ftpClient.GetCurrentDirectoryContents();
  
      foreach( String filename in RemoteFiles)
       if( String.Compare(filename, SearchPattern, ignoreCase) == 0)
              matchingFileNames.Add(filename);
  
      return matchingFileNames;
  }
  </code></pre>
  
  <p>Thanks in advance.</p>