SONYC
(SONYC)
1
Hello,
I want to get all files from a folder based on a specific pattern contained in the file name.
For this I use the next expression, but the syntax seems to be incorrect:
Directory.GetFiles(folderPath).Where(Function(x) x.Split("\"c).Last.ToString.Contains(str)).ToArray
How could I conditionally use the method Directory.EnumerateFiles() instead?
It seems to be more performant avoiding memory issues.
Parvathy
(PS Parvathy)
2
Hi @SONYC
Try this query:
Directory.EnumerateFiles(folderPath, "*.*", SearchOption.TopDirectoryOnly)
.Where(Function(x) Path.GetFileName(x).Contains(str))
.ToArray()
Hope it helps!!
SONYC
(SONYC)
3
Perfect. Thank you @Parvathy.
1 Like
system
(system)
Closed
4
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.