 <p>If you can specify what kinds of search strings this method will accept, you can use regular expressions. Here's an example which also uses Linq for brevity:</p> <pre><code>public IList&lt;String&gt; GetMatchingRemoteFiles(String SearchPattern, bool ignoreCase) { var options = ignoreCase ? RegexOptions.IgnoreCase : RegexOptions.None; return thirdPartyTool.ftpClient.GetCurrentDirectoryContents() .Where(fn =&gt; Regex.Matches(fn, SearchPattern, options)) .ToList(); } </code></pre> <p>Even if you cannot control what kinds of search strings this method accepts, it's still probably easier to convert the search string to a regular expression than write your own algorithm for matching the patterns. See <em>Bobson</em>'s answer for details on how to do this.</p>