• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

VB.net help -- multiple file types in .GetFiles

Homerboy

Lifer
Right now I have the following code:

Code:
Dim di As New DirectoryInfo(SourceFolderPath.Text)
Dim Filter = "*.pdf"
Dim fiArr As FileInfo() = di.GetFiles(Filter)

but I'd like to apply more "filters" so I can pull up more than just .pdf files.
Suggestions?

Thanks in advance.
 
Wrap another class around what you have
Pass in the filter
Parse the filter; make the GetFiles call; append the output into an array
Get the next filter and repeat.

At the end; you will have accomplished what you need and you have an array of file names containing the outputs.
 
I couldn't write VB to save my life, but you can get all of the files, then use Where to select the ones you want based on extensions. They aren't being filtered when you first index them, you're just keeping whichever ones match your list of extensions.

2nd or 3rd post: http://www.vbforums.com/showthread.php?664831-Multiple-file-extensions-with-GetFiles%28%29

I don't write VB, but it looks alright to me.

Code:
Dim fiArr As FileInfo() = di.GetFiles.[COLOR=#66cc66]Where[/COLOR][COLOR=#66cc66]([/COLOR][COLOR=#b1b100]Function[/COLOR][COLOR=#66cc66]([/COLOR]fi[COLOR=#66cc66])[/COLOR] fi.[COLOR=#66cc66]Extension[/COLOR] = [COLOR=#ff0000]".avi"[/COLOR] OrElse fi.[COLOR=#66cc66]Extension[/COLOR] = [COLOR=#ff0000]".mpg"[/COLOR] OrElse fi.[COLOR=#66cc66]Extension[/COLOR] = [COLOR=#ff0000]".mkv"[/COLOR] OrElse fi.[COLOR=#66cc66]Extension[/COLOR] = [COLOR=#ff0000]".mp4"[/COLOR][COLOR=#66cc66])[/COLOR].[COLOR=#66cc66]ToArray
[/COLOR]
 
Back
Top