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.
Basic String.Compare does not properly match the filename against the supplied pattern. Anyone know a more effective way of doing the matching please?
public IList<String> GetMatchingRemoteFiles(String SearchPattern, bool ignoreCase)
{
IList<String> matchingFileNames = new List<String>();
var RemoteFiles = thirdPartyTool.ftpClient.GetCurrentDirectoryContents();
foreach( String filename in RemoteFiles)
if( String.Compare(filename, SearchPattern, ignoreCase) == 0)
matchingFileNames.Add(filename);
return matchingFileNames;
}
Thanks in advance.