1.11M Members

Using Directory.GetFiles() WITH multiple extensions AND sort order

 
0
 

Hi,

I have to get a directory file list, filtered on multiple extensions...and sorted!

I use this, which is the fastest way I've found to get dir content filtered on multiple extensions:

Dim ext As String() = {"*.jpg", "*.bmp","*png"}
Dim files As String() = ext.SelectMany(Function(f) Directory.GetFiles(romPath, f)).ToArray
Array.Sort(files)

and then use an array sort.

I was wondering (and this is my question ;)) if there would be a way to do the sorting IN the same main line? A kind of:

Dim files As String() = ext.SelectMany(Function(f) Directory.GetFiles(romPath, f).**Order By Name**.ToArray

and, if yes, if I would gain speed doing this instead of sorting the array at the end (but I would do my test and report..as soon as I get a solution!!)?
Thanks for your help!!

 
0
 

Here is a link to an application that reads on a pretty low level. (MFT)

This would be quicker, but possibly some unnessesary overhead.

The problem alot of programmers have, including myself, is the habbit of over engineering an application. Sometimes simpler is better.

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article