Directory.GetDirectories display order

Discussion in 'ASP .Net' started by =?Utf-8?B?TWlrZSBE?=, Mar 30, 2005.

  1. 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
     
    =?Utf-8?B?TWlrZSBE?=, Mar 30, 2005
    #1
    1. Advertising

  2. 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

    "Mike D" wrote:

    > 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
     
    =?Utf-8?B?TWlrZSBE?=, Mar 30, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. frederik

    GetDirectories UNC path - Acces Denied

    frederik, Feb 1, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    4,817
    frederik
    Feb 2, 2005
  2. Soren Kuula
    Replies:
    2
    Views:
    504
    Soren Kuula
    Feb 1, 2004
  3. Nathan Sokalski
    Replies:
    2
    Views:
    1,132
  4. cspoh
    Replies:
    0
    Views:
    252
    cspoh
    Jul 31, 2003
  5. Stephan Kämper
    Replies:
    2
    Views:
    240
    Stephan Kämper
    Jan 18, 2004
Loading...

Share This Page