does anyone know how to search a mobile device for a particular file extention?
I would like to find a way to search all folders for .tsk files and have the results added to a combobox.
Printable View
does anyone know how to search a mobile device for a particular file extention?
I would like to find a way to search all folders for .tsk files and have the results added to a combobox.
Hi,
try this, which returns everything sorted in an array - should be pretty easy to mod.
Pete
vb Code:
Public arrBases As ArrayList ... arrFiles = New ArrayList Search_For_Bases("\","*.txt") Add_Files_From_Root(".txt") arrFiles.Sort() ... Public Sub Search_For_Files(ByVal sDir As String, ByVal sExt as string) Dim d As String = "" Dim f As String = "" Try For Each d In Directory.GetDirectories(sDir) Search_For_Files(d) For Each f In Directory.GetFiles(d, sExt) Check_Files(f) Next Next Catch excpt As System.Exception .... End Try End Sub Public Sub Check_Files(ByVal fn As String) arrFiles.Add(fn) End Sub Public Sub Add_Files_From_Root(ByVal sExt as string) Dim FS As New DirectoryInfo("\") Dim fileInfo As FileInfo For Each fileInfo In FS.GetFiles() If LCase(fileInfo.Extension) = sExt Then Check_Files(fileInfo.FullName) End If Next End Sub
Note:
Search_For_Bases("\","*.txt") is mistakenly written, i think you wanted to write
Search_For_Files(("\","*.txt")
Correct - you spotted the deliberate mistake :)
Ok then :p