Thread: GetFiles() Help
View Single Post
  #4 (permalink)  
Old April 5th, 2008, 01:58 PM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You're not declaring secondArray as an array (using ()) but even if you would, it wouldn't have an Add method. Instead of an array you can use a generics List (Of FileInfo) instance like this:
Code:
Imports System.Collections.Generic

Dim specificFile As FileInfo
Dim filteredList As New List(Of FileInfo)

For Each specificFile In fileArray
  If specificFile.Extension = ".htm" Or specificFile.Extension = ".ppt" Then
    'collect files with desired extensions
    filteredList.Add(specificFile)
  End If
Next specificFile
dgArticleList.DataSource = filteredList
dgArticleList.DataBind()
If you don't want GetFiles to do any filtering, there's no need to pass *.* as the search pattern. The parameterless version of GetFiles gets all files by default.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.