Using System.IO.Directory.GetFiles()
, I would like to find images .png
extension located on NAS server.
string searchingString = "ZLLK9";
// original
var fileList1= Directory.GetFiles(directoryPath).Select(p => new FileInfo(p)).Where(q => q.Name.Substring(0, q.Name.LastIndexOf('.')).Split('_').First() == searchingString);
// fixed
var fileList2 = Directory.GetFiles(directoryPath, string.Format("{0}_*.png", searchingString));
There are two ways to find out files contain "ZLLKK9" words.
The first 'original' way using LINQ is too slow to find out the files. The performance issues are up but I don't know what is different with 'fixed' way?
I need help for understanding the difference with two ways carefully.