DirectoryInfo GetDirectories Reverse

StewartBW 1,830 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 :)

Developer technologies | VB
Developer technologies | C#
0 comments No comments
{count} votes

Accepted answer
  1. Marcin Policht 50,730 Reputation points MVP Volunteer Moderator
    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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.