Import filenames into daatagrid

  • Thread starter Thread starter Alan Z. Scharf
  • Start date Start date
A

Alan Z. Scharf

1. I would like to have a function which looks at a specified directory and
loads each filename into datagrid

2. If possible, I would like to have the File Type and DataModified parsed
into separate columns in the table.

Any direction would be appreciated.

Thanks.

Alan

___________________________
Alan Z. Scharf
GrapeVine Systems
New York City
 
You can use a DirectoryInfo and then iterate through it adding the FileInfo
information

DirectoryInfo di = new DirectoryInfo(@"C:\someDirectory\");


foreach (FileInfo fi in di.GetFiles()){

}
THen you can add the filename to a DataTable for intance, column0, and then
have two other columns and add the values to it. Once you have populate the
DataTable, bind your grid to it with dataGrid.DataSource = dataTable;

You could also use a listview and do something like this

foreach (FileInfo fi in di.GetFiles()){
ListViewItem i = new ListViewItem;

//use the same for subitems...addiing datemodified and filesize.
}

Let me know if you have any problems.

Cheers,

Bill
 
Back
Top