DirectoryInfo - Multiple file formats

  • Thread starter Thread starter JANEMAN
  • Start date Start date
J

JANEMAN

Hi guyz.

I am using DirectoryInfo to get the list of files from 1 directory and
then display it in grid. I am using ASP.NET with VB.NET code behind.

But I have to pick 2 different kind of files and leave rest alone. The
following code doesn't seem to be working. Where is the wrong
syntex..?

Code:
dgFileList.DataSource = myDirInfo.GetFiles("*.GIF|*.txt")

dgFileList is a DataGrid from ASP.NET Can some please help me..?

Cheers.
 
The syntax you've used is used for the filter on dialogs, but is not valid for the GetFiles method

In order to achieve your desired results, you will need to call the GetFiles method twice. Something like this

Dim aFiles as New ArrayLis

aFiles.AddRange(myDirInfo.GetFiles("*.txt")
aFiles.AddRange(myDirInfo.GetFiles("*.GIF")
dgFileList.DataSource = aFile
 
Back
Top