how to sort folders read out recursively

In order to to build up a menu structure i read out a special folders with all its subfolders recursively. Now the problem is, that they are unsortet, better, i can't see where the parent folders of them. Example:
Folder1 ->Subfolder1 ->SubSubfolder1
        ->Subfolder2 ->sSubfolder1
now the result of my recursive search is
SubSubfolder1, SubSubfolder2, Subfolder1, sSubfolder1, sSubfolder2, Subfodler2, Folder1
Now i want to mark them eg like this:
f1s1SubSubfolder1, f1s1SubSubfolder2, f1Subfolder1, f1s2SubSubfolder1, f1s2SubSubfolder2, f1Subfolder2, Folder1.
Does anybody know how to do this??
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.

TimCotteeHead of Software ServicesCommented:
Could you post the code you are using to generate the recursed list, then perhaps I can see a way to sort it.
evilTAuthor Commented:
  function getsubfolders(path)
  Dim fso, f, f1, s, sf
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set f = fso.GetFolder(path)
  Set sf = f.SubFolders
  For Each f1 in sf
      pfad = path&"\"&
      response.write( & " ")
  end function

By the way: i use it in an asp - page
TimCotteeHead of Software ServicesCommented:
First thing is that you should move the response.write to before the getsubfolders call, this will put your parent at the top of the list.

Try This, it is not quite the prefixing structure you suggest but is probably clearer especially if there are more than two levels.

Function getsubfolders(path, prefix)
    Dim fso, f, f1, s, sf
    Dim fnum As Integer
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fso.GetFolder(path)
    Set sf = f.SubFolders
    For Each f1 In sf
        fnum = fnum + 1
        pfad = path & "\" & f1.Name
        Response.Write(prefix & CStr(fnum) & ":" & f1.Name & " ")
        getsubfolders pfad, prefix & CStr(fnum) & ":"
End Function

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
evilTAuthor Commented:
Hey cool, i think thats exactly what i wanted, thx a lot
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
Visual Basic Classic

From novice to tech pro — start learning today.