Good day,
I am using c# from VS2005.
I am loading a datatable with the filenames and such from a given
directory using the following code:
arrFileList = GetAllFiles("c:\\sample", true);
dtJobs.BeginLoadData();
try
{
foreach (string sFile in arrFileList)
{
NewDataRow = dtJobs.NewRow();
sFileName = Path.GetFileName(sFile);
sFilePath = Path.GetDirectoryName(sFile);
NewDataRow.ItemArray = new object[] {sFileName, sFilePath};
dtJobs.Rows.Add(NewDataRow);
}
}
finally
{
dtJobs.EndLoadData();
}
I am using a table because I plan to use the DexExpress XtraGrid.
But for testing there are only 20 or some files in the directory and
yet this method is rather slow. Is there a better way to populate the
table (there is a timer and the data will be refreshed on a regular
basis).
The loading of the table is the slow part. The directory access and
everything else is very quick.
Thanks for any ideas.
-Markus_R