'Example of listing the file & folders from the dirapp folder
Sub ListFolders
Dim l As List = File.ListFiles(File.DirApp)
For i = 0 To l.Size - 1
Log(l.Get(i) & " = Folder: " & isDir(l.Get(i)))
Next
End Sub
'Check if a file is a folder
'Return true if file is folder
Sub isDir(f As String) As Boolean
Dim fileO As JavaObject
fileO.InitializeNewInstance("java.io.File", Array As Object(f))
Return fileO.RunMethod("isDirectory", Null)
End Sub
Sub AppStart (Args() As String)
Log(ListFolders("c:\temp"))
End Sub
Sub ListFolders(folder As String) As List
Dim folders As List
folders.Initialize
For Each f As String In File.ListFiles(folder)
If File.IsDirectory(folder, f) Then folders.Add(File.Combine(folder,f))
Next
Return folders
End Sub
Does anybody know if there is any way to sort the Folders to the top, the same as when you click on the "Name" column in Windows File Explorer. It's taking 30 to 40 seconds to go thru some of my folders to find if a folder contains any Sub Folders
Some of my image folders have thousands of images and they may also have sub folders as well
I want to find the sub folders only and searching the whole folder, using your routine above, can take 30 to 40 seconds.
If I can sort the items in the folder so the folders come first, when I find an entry containing a ".", I can assume there are no more folders, so can exit the loop.
I tried the MFLib library and found that it was faster (quite a bit) on the computer that the .jar was running on but it was a lot slower when accessing a Server.
You may be able to modify this to suit your needs, it can list > 3000 files in about 800ms.
Plus you can get file names or just the folders in a directory.
Absolutely brilliant Daestrum, it took 6800ms (instead of the 20 minutes) before to go thru 89000 files and 600 folders.
I know nothing about java but had a feeling that java could do the trick, but I searched the Internet for any references and couldn't find anything, not that I could have coded it even if I did find a reference.
Thanks again, that's terrific, it will make my app usable rather that having 20 minutes to get an index of the folders