see Directory.EnumerateFiles. It has ignore no access files:
var folder = @"c:\code";
var match = "*.cs";
var maxSize = 100;
var filePaths = Directory.EnumerateFiles(folder, match, new EnumerationOptions
{
IgnoreInaccessible = true,
RecurseSubdirectories = true
}).Where(f =>
{
var fileInfo = new FileInfo(f);
return fileInfo.Length < maxSize;
});
https://learn.microsoft.com/en-us/dotnet/api/system.io.directory.enumeratefiles?view=net-8.0
note: the windows file system is just not fast at searching for files.