I would like an easy way to count the number of files in a directory using D.
As far as I can tell from the D manual, dirEntries returns a range, but this has no length property. I therefore have to iterate through the results with a counter, or gather up the names in a traditional array which I can find the length of... Is there a better way?
auto txtFiles = dirEntries(".", "*.txt", SpanMode.shallow);
int i=0;
foreach (txtFile; txtFiles)
i++;
writeln(i, " files found..");