How do I sort dirInfo.GetFiles("*.*") by name in reverse order?

I am displaying a list of files from a directory and they by default are displayed in alphabetical order ascending (A - Z) by filename.

I would like to reverse the order  (Z - A) on how they are displayed by filename.

Code I am currently using:
===============================================
Dim dirInfo As New DirectoryInfo(strDir)

        articleList.DataSource = dirInfo.GetFiles("*.*")
        Dim FileCount As Integer = dirInfo.GetFiles("*.*").Length
        articleList.DataBind()
===============================================

Any help would be appreciated, Thanks
rpizzoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

grayeCommented:
What is articleList ?  Perhaps a DataGridView? or ListView?
0
lazyberezovskyCommented:
Go this way
DirectoryInfo di = new DirectoryInfo(Environment.CurrentDirectory);
FileInfo[] files = di.GetFiles();
Array.Reverse(files);
articleList.DataSource = files;

Open in new window

0
AkshCommented:
Hi rpizzo,

You may use Array.Reverse() method to cater the requirement.

Code: Check for the comment having the name Aksh.
===============================================
Dim dirInfo As New DirectoryInfo(strDir)
       Dim f() As FileInfo = dirInfo.GetFiles("*.*")  ''Aksh: Getting the information in an array
        Array.Reverse(f) 'Aksh: Reversing an array.
        articleList.DataSource = f 'Aksh: Binding reversed array to control
        Dim FileCount As Integer = dirInfo.GetFiles("*.*").Length
        articleList.DataBind()
===============================================

-Aksh
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

lazyberezovskyCommented:
VB for you
Dim files As FileInfo() = dirInfo.GetFiles()
Array.Reverse(files)
articleList.DataSource = files

Open in new window

0
PaulHewsCommented:
I agree with lazyberezovsky, but I would strongly suggest that you call Array.Sort on the array before calling Reverse.  

Directory.GetFiles does not guarantee that the files will be in any sorted order:

See remarks section
http://msdn.microsoft.com/en-us/library/07wt70x2.aspx
0
rpizzoAuthor Commented:
Te quick response was appreciated.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.