Greating Flippo)i'm work with soirce of your explorer but not find,how can i do it.you find files in subfolder when click it.but i must find all files at once
Adds all subdirectories matching the search pattern in the specified path to an ArrayList and returns the number found.
Syntax: DirSearch (ArrayList, Path [,Search Pattern])
If the Search Pattern is omitted DirSearch will return all the subdirectories in the directory.
Search Pattern can include '*' and '?'.
* - Finds zero or more characters.
? - Finds exactly one character.
Example: (alDir is an ArrayList control)
FileSearch (alDir, "\My Documents")
This example will add all the subdirectories in My Documents folder (in the device) to the ArrayList alDir.
Adds all files matching the search pattern in the specified path to an ArrayList and returns the number of files found.
Syntax: FileSearch (ArrayList, Path [,Search Pattern])
If the Search Pattern is omitted FileSearch will return all the files in the directory.
Search Pattern can include '*' and '?'.
* - Finds zero or more characters.
? - Finds exactly on character.
Example: (alFiles is an ArrayList control)
FileSearch (alFiles, "\My Documents", "*.txt")
This example will add all the files with txt extension in My Documents folder (in the device) to the ArrayList alFiles.
use a bit of logic...
if root folder has subdir, then search each subdir for folders...Until the result is 0Then you will have a series of array with ALL THE SUBFOLDERS OF YOUR MAIN ROOT
Same with the files...
Example:
IF DirSearch(Root(),"\MyDocuments")>0 Then
For x=0 to arraylen(root())-1
Textbox1.text=TextBox1.text&Root(x)&crlf 'this will populate a textbox with the root values
Next
For x=0 to Arraylen(Root())-1
DirSearch(Control(Level(),Root(x))
Textbox1.text=TextBox1.text&Root(x)&crlf
Next
End If
NOTE this is untested code, root and level are arraylist controls...
Cableguy you read my post?i must find ALL FILES in folder,sub-folders,subsub-folders,subsubsub-folders,subsubsub-folders...subsubsubsubsubsubsubsubsubsubsubsub-folders.
yes,you may use 1000 cicles and create 1000 arraylists...but i want a beautiful way...
p.s. in your code your have some errors)and your cade show only folders from root
Sub Globals
'Declare the global variables here.
End Sub
Sub App_Start
Form1.Show
FindAllFiles("\My Documents")
For i = 0 To alFiles.Count-1
listbox1.Add(FileName(alFiles.Item(i))) 'Remove FileName if you need the full
Next
End Sub
Sub FindAllFiles(root)
alFolders.Clear 'ArrayList
alFiles.Clear 'ArrayList
alFolders.Add(root)
i = 0
Do While alFolders.Count > i
'search one folder
currentFolder = alFolders.Item(i)
DirSearch(alFolders,currentFolder) 'Add all subfolders in this folder to the list.
FileSearch(alFiles,currentFolder,"*.*") 'Add all files from this folder.
b = alFiles.Count
i = i + 1
Loop
End Sub
I'm getting an error everytime with "end sub" on the findallfiles sub.... and without it i get an argument out of range exception. Anyone know what i'm doing wrong?
B4X:
Sub App_Start
Form1.Show
FindAllFiles("\Storage Card\Program Files")
For i = 0 To alFiles.Count-1
listbox1.Add(FileName(alFiles.Item(i))) 'Remove FileName if you need the full
Next
End Sub
Sub FindAllFiles(root)
alFolders.Clear 'ArrayList
alFiles.Clear 'ArrayList
alFolders.Add(root)
i = 0
Do While alFolders.Count > i
'search one folder
currentFolder = alFolders.Item(i)
DirSearch(alFolders,currentFolder) 'Add all subfolders in this folder to the list.
FileSearch(alFiles,currentFolder,"*.exe*") 'Add all files from this folder.
b = alFiles.Count
i = i + 1
Loop
I'm trying to write a program that will restore all of my shortcuts to my start menu after flashing.
EDIT: from what i can tell... the out of range exception has something to do with arrays.