Open DinisCruz opened 10 years ago
Actually this is not that easy to fix since the current search is done using the .NET GetFiles methods which is the one that fails when one file cannot be accessed
var searchOptions = (bSearchRecursively) ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
String[] sFileMatches = Directory.GetFiles(sStartDirectory, sSearchPattern, searchOptions);
Try Directory.Enumerate instead of GetFiles
That should work
From http://msdn.microsoft.com/en-us/library/dd997370(v=vs.110).aspx
foreach (var fi in diTop.EnumerateFiles())
{
try
{
// Display each file over 10 MB;
if (fi.Length > 10000000)
{
Console.WriteLine("{0}\t\t{1}", fi.FullName, fi.Length.ToString("N0"));
}
}
catch (UnauthorizedAccessException UnAuthTop)
{
Console.WriteLine("{0}", UnAuthTop.Message);
}
}
it looks like diTop.EnumerateFiles()
is not the one that throws the exception
@nacht wanna try to give this a go and send a PR :)
let me see if i can get a mono stack running locally :)
take a look at http://blog.diniscruz.com/search/label/OSx
that might help
in https://github.com/o2platform/FluentSharp/blob/master/FluentSharp.CoreLib/O2_DotNetWrappers/Windows/Files.cs#L274
At the moment if there is an access denied in one of the files or folders, there will be no results returned
The expectation is that the files that are currently available to the user should be returned, and that any errors should be logged