|
-
Jan 14th, 2007, 02:50 PM
#1
Thread Starter
Addicted Member
diretory.getfile("c:\","*.jpg")..more file extension filter
i want to get all files *.jpg,*.gif..how can i specify more than 1 extension type??
-
Jan 14th, 2007, 04:19 PM
#2
Re: diretory.getfile("c:\","*.jpg")..more file extension filter
Separate each extension with a semicolon, "*.jpg;*.gif"
-
Jan 14th, 2007, 04:38 PM
#3
Thread Starter
Addicted Member
Re: diretory.getfile("c:\","*.jpg")..more file extension filter
i already tried this...but it doesn't seem to work
-
Jan 14th, 2007, 05:57 PM
#4
Addicted Member
Re: diretory.getfile("c:\","*.jpg")..more file extension filter
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
-
Jan 14th, 2007, 06:14 PM
#5
Thread Starter
Addicted Member
Re: diretory.getfile("c:\","*.jpg")..more file extension filter
that's not very practical
-
Jan 14th, 2007, 06:29 PM
#6
Re: diretory.getfile("c:\","*.jpg")..more file extension filter
Perhaps like this
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
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".
Last edited by Atheist; Jan 14th, 2007 at 06:35 PM.
-
Jan 14th, 2007, 06:37 PM
#7
Re: diretory.getfile("c:\","*.jpg")..more file extension filter
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
This code is VB 2005-specific. Please ALWAYS specify your version. In previous versions you'd use a StringCollection instead of a List.
-
Jan 15th, 2007, 02:08 AM
#8
Thread Starter
Addicted Member
Re: diretory.getfile("c:\","*.jpg")..more file extension filter
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|