Using Directory.GetFiles() WITH multiple extensions AND sort order
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

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

  1. #1
    Join Date
    Apr 2011
    Posts
    15

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

    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:

    Code:
    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:
    Code:
    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!!

  2. #2
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,987

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

    or, just shell EXPLORER with the parameters
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center