I was wondering if it were possible to perform an operation on every element returned in a LINQ query at the same time as performing the query itself.
Example:
var files = Directory.EnumerateFiles(@"C:\etc", "*.*", SearchOption.AllDirectories)
.Where(s => (s.ToLower().EndsWith(".psd"))
&&
new FileInfo(s).Length > 500000);
finds all files within set criteria, but if I wanted to say trim “C:\” from each string that was returned, could I somehow say s = f(s) after the where clause or would this be a separate foreach each loop.
Thanks.
After the Where statement, you can add this
That will return the string with C:\ stripped.