private long CountFiles(string path, string type) { if (_fileSystem.IsCloudStorage) { // Dont't count, it's expensive! return(0); } Func <string, bool> predicate = null; if (type.HasValue() && type != "#") { type = type.ToLowerInvariant(); predicate = x => GetFileContentType(Path.GetExtension(x)) == type; } return(_fileSystem.CountFiles(path, "*", predicate, false)); }