Well, you are getting that error because those are not defined by that
function. That function returns an array of strings. Here is what i did
when i had a similar thing to do (I list out all the images in a folder).
Basically, there are 2 parts to it - the DirectoryConents class, and an
array list to hold the directory contents.
The directory contents class is defined as follows -
public class DirectoryContents
{
private string _Name;
private DateTime _LastWriteDate;
public string Name
{
get { return this._Name; }
set { this._Name = value; }
}
public DateTime LastWriteDate
{
get { return this._LastWriteDate; }
set { this._LastWriteDate = value; }
}
// constructor
public DirectoryContents(string ItemName, DateTime
WriteDate)
{
this.Name = ItemName;
this.LastWriteDate = WriteDate;
}
}
Then I have a function that returns an array list (you can bind directly to
an ArrayList). It does the following. -
// note, static is only because I was calling this from a seperate code file
public static ArrayList GetFiles(string Path)
{
// lets us use Server.MapPath
HttpContext context = HttpContext.Current;
// get list of all images in the current directory
DirectoryInfo ParentDirectory = new
DirectoryInfo(context.Server.MapPath(Path));
// Arraylist to hold the files
ArrayList DirectoryContents = new ArrayList();
// loop through all the files
foreach (FileInfo ReportFile in ParentDirectory.GetFiles())
{
// only return the reports (rpt extension)
if (ImageFile.Extension.ToLower() == ".rpt")
{
// create a new instance of the
DirectoryContents class
DirectoryContents.Add(new
DirectoryContents(ReportFile.Name.ToString().Replace(".rpt", ""),
ReportFile.LastWriteTime));
}
}
// return the data
return DirectoryContents;
}
I'll work on converting this to VB.Net syntax, but you can see what I am
basically doing. The class holds the data for each file. You can also add
more fields depending on what you need (file name, file path, create date,
etc).
Then I call a function called GetFiles and pass in the path to the folder I
want to get files for (you could pass in the absolute location, I pass in a
relative location then I map the path). Basically what this function does
is it creates an arraylist (which will be returned later), loops through all
the files in the directory, if the file is a report, we add a new instance
of our DirectoryContents class to the arraylist. When we are done we return
the arraylist to wherever (could return to DataGrid.DataSource).
When you bind to the ArrayList to the datagrid, you reference the DataItems
by the public name in the class. So for example, a bound column that was to
display the last write date would reference the data field as LastWriteDate.
You would reference the file name as Name, etc.
Hope this helps. In my app I was listing out all image files, and I found
the approach I used to be quick and efficient way of grabbing the data.
-Darren