Directory.GetDirectories display order

G

Guest

Can I control the order that files, folders are displayed? Can I do them
alphabetically or do I need to upload to a db like we did in asp?

items = Directory.GetDirectories(path)
For Each item In items
Response.Write(Replace(item, "F:\Inetpub\wwwroot\", "") & " <br
/>")
Next

Thanks
Mike
 
G

Guest

Not pretty but it works

Public Function GetFolderInfo(ByVal strPath As String) As String
Dim item As String
Dim items() As String
Dim path As String = "F:\Inetpub\wwwroot\" & strPath

Dim arFolderArray As String

items = Directory.GetDirectories(path)

For Each item In items
arFolderArray = arFolderArray & Replace(item, path & "\", "") &
","
Next

Dim arFolder As Array
arFolderArray = Left(arFolderArray, Len(arFolderArray) - 1)

arFolder = Split(arFolderArray, ",")
Array.Sort(arFolder)
Dim x As Integer = 0

For x = 0 To UBound(arFolder)
Response.Write(arFolder(x) & " <br />")
Next
End Function

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top