DirectoryInfo GetDirectories Reverse

StewartBW 745 Reputation points
2024-05-19T15:25:17.47+00:00

Hello,

Using this code and need to reverse the list returned by GetDirectories:

Dim di As New DirectoryInfo(path)

Dim di2 As DirectoryInfo() = di.GetDirectories

How to reverse di2 list?

Thanks :)

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,573 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,642 questions
0 comments No comments
{count} votes

Accepted answer
  1. Marcin Policht 16,730 Reputation points MVP
    2024-05-19T15:38:53.6433333+00:00

    Try the following

    Dim di As New DirectoryInfo(path)

    Dim di2 As DirectoryInfo() = di.GetDirectories()

    ' Reverse the di2 array

    Array.Reverse(di2)

    ' Now di2 contains the directories in reverse order


    If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    hth

    Marcin

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful