i want to get all files *.jpg,*.gif..how can i specify more than 1 extension type??
Printable View
i want to get all files *.jpg,*.gif..how can i specify more than 1 extension type??
Separate each extension with a semicolon, "*.jpg;*.gif"
i already tried this...but it doesn't seem to work
I find that is a limitation in .NET.
VB Code:
Dim mFileExt() As String = {"mp3", "m4a"}
Something similar to this code should do the job.
VB Code:
For Each fileExt As String In mFileExt 'Console.WriteLine("Dir: " & recordPath) For Each filePath As String In Directory.GetFiles(recordPath, "*." & fileExt, SearchOption.AllDirectories) ' Console.WriteLine(filePath) listAddableFiles.Add(filePath) Next Next
:( that's not very practical
Perhaps like this
EDIT: But I guess it would be even better to avoid the FileInfo class, as retrieving the files as strings doesnt take as much "resources".VB Code:
Dim strExtensions() As String = {".jpg", ".zip"} For Each fi As IO.FileInfo In New IO.DirectoryInfo("h:\").GetFiles If Not Array.IndexOf(strExtensions, fi.Extension) = -1 Then ' Do what you want End If Next
This code is VB 2005-specific. Please ALWAYS specify your version. In previous versions you'd use a StringCollection instead of a List.VB Code:
Dim folderPath As String = "folder path here" Dim filePaths As List(Of String) Dim patterns As String() = {"*.jpeg", "*.jpg"} For Each pattern As String In patterns filePaths.AddRange(IO.Directory.GetFiles(folderPath, pattern)) Next pattern
ok thanks...i guess i will get all files and check if the files are within the extensions i want using getfileinfo.getextension a bit similar to how i was doin in vb6