------------------------------------------------------DirSearch
--------------------------------------------------------------------------------
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.
FileSearch
--------------------------------------------------------------------------------
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.
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
Not at all. This was an interesting question with a nice answer.It must frustrate the more experienced users sometimes
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
Thanks much, cant believe i didnt see that haha....Joel, you can safely remove the
Code line from the code, and the error will no longer be trigged, or simply un-check the "check un-used variable" option...B4X:b = alFiles.Count