Is there a more efficient way to filter file names using Directory.GetFiles and 'StartsWith', 'Contains' and 'EndsWith' with rather than the way I am currently doing it?
_files = Directory.GetFiles(_path);
if (!String.IsNullOrEmpty(_startsWith))
{
_files = _files.Where(x => x.StartsWith(_startsWith)).ToArray();
}
if (!String.IsNullOrEmpty(_contains))
{
_files = _files.Where(x => x.Contains(_contains)).ToArray();
}
if (!String.IsNullOrEmpty(_endsWith))
{
_files = _files.Where(x => x.EndsWith(_endsWith)).ToArray();
}