public static List<string> GetFilesListing(string searchPath, char directorySeparatorChar, IDirectory dir)
{
VerifyArgument.IsNotNull("Directory",dir);
int lastIndexOfDirSepChar = searchPath.LastIndexOf(directorySeparatorChar);
var queryCollection = new List<string>();
if(lastIndexOfDirSepChar > 0)
{
var parentDir = searchPath.Substring(0, lastIndexOfDirSepChar + 1);
var searchPattern = string.Format("*{0}*", searchPath.Substring(lastIndexOfDirSepChar + 1));
if (dir.Exists(parentDir))
{
queryCollection = new List<string>(dir.GetFileSystemEntries(parentDir, searchPattern));
}
}
return queryCollection;
}