That query is mostly equivalent to:
long diskSpace = (from directory in Directory.EnumerateDirectories(@"c:\")
from file in Directory.EnumerateFiles(directory)
select file)
.Sum(file => new FileInfo(file).Length);
(I've renamed fileSize
to file
to more accurately represent the meaning, btw.)
There's one actual difference in this case - we're creating a new delegate which calls Directory.EnumerateFiles
rather than directly creating a delegate from the Directory.EnumerateFiles
method group. In other words, it's one extra level of redirection - but this won't have any effect on the results and I'd be amazed if it had any significant performance impact.