using FileSystemObject to get subfolders
Hi
I'm using this code to get subfolders but i got them arranged by modify time
How can i make them arrange by name
"Changing folder sort type form windows explorer makes no change"
VB Code:
Dim FS As New FileSystemObject
Dim FSfolder As Folder
Dim subfolder As Folder
Dim i As Integer
Set FSfolder = FS.GetFolder(progpath + "data\")
ReDim installed(FSfolder.SubFolders.Count - 1)
i = 0
For Each subfolder In FSfolder.SubFolders
DoEvents
installed(i) = subfolder.Name
i = i + 1
Next subfolder
Set FSfolder = Nothing
Re: using FileSystemObject to get subfolders
Quote:
Originally Posted by Tnen
... How can i make them arrange by name
"Changing folder sort type form windows explorer makes no change" ...
That's because "actual" sort order is unknown - remember, Windows Explorer is an application so it was programmed to do things but you're getting list of folders/subfolders/files directly from system and god knows how they are all arranged.
What I may suggest is to use Listview control so you can load names/dates/etc so you can sort on a column you wish.
Re: using FileSystemObject to get subfolders
Being sorted by date modified is logical - that's probably how the file system works. Not that I have any intimate knowledge of it.
Quote:
Originally Posted by RhinoBull
What I may suggest is to sue Listview control
I thought of that once, but the legal fees put me off :(
Re: using FileSystemObject to get subfolders
Why don't you just sort the array installed() when all sub folders are loaded into it.
Re: using FileSystemObject to get subfolders
Quote:
Originally Posted by penagate
...I thought of that once, but the legal fees put me off :(
LOL ... :)
Re: using FileSystemObject to get subfolders
thanks for replies but
how to
Quote:
Why don't you just sort the array installed() when all sub folders are loaded into it.
Re: using FileSystemObject to get subfolders
Quote:
Originally Posted by Tnen
thanks for replies but
how to
You can use bubble sorting.
http://iweb.tntech.edu/bhuguenard/ds3850/bubbleSort.htm
This example uses an integer array, but it works just as good with a string array.