how to search files

Apr 7, 2014 at 5:26 PM
How to search files with multiple extensions without throwing an exception

Thanks in advance
Apr 8, 2014 at 11:41 AM
Edited Apr 8, 2014 at 1:49 PM
I have also considered this scenario during the developemtn and came to the conclusion that QuickIO needs no filter at the moment.
There are no advantages when I apply a filter directly in the Win32 API.
Therefore I recommend LINQ, which is more flexible and faster at this point. Win32 operations (FindFirstFile, FindNextFile) are slower, if I pass for example _*.png instead of *.

So please use LINQ to filter received data. LINQ works with .NET 2.0 too. Just reference directly to the dll and set "copy local = true".
In this lib I using some LINQ extensions too, see https://quickio.codeplex.com/SourceControl/latest#rel/v1.0.0.1/source/QuickIO/Compatibility/NETCompatibility.cs

I could add System.Linq.dll, but I do not want to have any external relations on the core assembly and I am not allowed to deliver the Linq dll standalone.

What error did you get?
Apr 10, 2014 at 3:12 PM
Thank you, clearly
What error did you get?
For example to search on disk C
"Access to 'C:\Documents and Settings' denied."

Use the following code
IEnumerable allSubFolders = QuickIODirectory.EnumerateDirectories(@"C:\", SearchOption.AllDirectories);
foreach (QuickIODirectoryInfo directoryInfo in allSubFolders)
{
  Console.WriteLine("Directory found: {0} Readonly: {1}", directoryInfo.FullName, directoryInfo.IsReadOnly);
}
I thought maybe there is a method of putting out the call exception

Thanks in advance
Apr 10, 2014 at 3:30 PM
The problem at this position is, Win32 API returns an internal handle of a folder of another user -> no access.
The error at this point is correct.

I'll figure out a solution. For example the indication by flags, which exception in searches should be ignored.
Apr 10, 2014 at 3:41 PM
Yes all right
it would be good
Apr 10, 2014 at 7:23 PM
I have a pretty good idea. I will publish a new version on the weekend or Monday.
Apr 14, 2014 at 10:03 AM
Edited Apr 14, 2014 at 10:24 AM
Hi kolwer,

error is fixed. Usage will be:

        [TestMethod, TestCategory( "Directory" )]
        [ExpectedException( typeof( UnauthorizedAccessException ) )]
        public void Directory_Enumeration_NoAccess()
        {
            QuickIODirectory.EnumerateDirectoryPaths( @"C:\temp" ); //no access to C:\temp\quickIO_permissiontest
        }

        [TestMethod, TestCategory( "Directory" )]
        public void Directory_Enumeration_NoAccessIgnored()
        {
            var s = QuickIODirectory.EnumerateDirectoryPaths( @"C:\temp", enumerateOptions: QuickIOEnumerateOptions.SuppressAllExceptions );
        }
I will add a filter extension function, too. I think it will be finished tomorrow.
Apr 15, 2014 at 9:43 PM
a new version has been published.
the filter function will be added soon. have some pattern problems with .net 2.0
Jun 23, 2014 at 7:12 PM
Native Win32 pattern for filter is integrated in next release.
Marked as answer by BenjaminAbt on 6/23/2014 at 11:12 AM