Thread: GetFiles() Help
View Single Post
  #1 (permalink)  
Old April 4th, 2008, 03:43 PM
adamcherochak adamcherochak is offline
Authorized User
 
Join Date: Sep 2007
Location: , , .
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default GetFiles() Help

Greetings,
I need help with a GetFiles() to return multiple file extensions. I think I am close with the included bit of code. However, it is not filtering like I desire. It returns all files if any file has an extension of my If statement. I want it to return only those files with the desired extension.

I think I might need a table adapter but I'm not using a database.

Code:
Dim dirInfo2 As NewDirectoryInfo(Server.MapPath("///.\UploadFolder\"))
        Dim fileArray As FileInfo() = dirInfo2.GetFiles()
        Dim specificFile As FileInfo
        For Each specificFile In fileArray
            If specificFile.Extension = ".htm" Then
                'add to data source
                dgArticleList.DataSource = fileArray 'PROBLEM HERE
            End If
        Next specificFile
        dgArticleList.DataBind()