> The loading of the table is the slow part. The directory access and
> everything else is very quick.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jon wrote:
> Could you post a short but complete program which demonstrates the
> problem?
Hey Jon,
Good exercise for me. I quickly found the problem that I overlooked. I
lookup the filename in a database and that was the slowdown. <doh>
I will post my database access question instead.
I am posting my example in case it helps any one populate an in-memory
table.
namespace SampleListDir
{
public partial class Form1 : Form
{
private DataTable data;
public Form1()
{
InitializeComponent();
string[] arrFileList;
string sFileName;
int i = 1;
data = new DataTable("dtJobs");
data.BeginInit();
AddColumn(data, "ID",
System.Type.GetType("System.Int32"), true);
AddColumn(data, "Filename",
System.Type.GetType("System.String"),false);
data.EndInit();
data.Clear();
this.Cursor = Cursors.WaitCursor;
data.BeginLoadData();
try
{
arrFileList =
Directory.GetFiles("C:\\WINDOWS\\system", "*.*", 0);
foreach (string sFile in arrFileList)
{
sFileName = Path.GetFileName(sFile);
data.Rows.Add(new object[] { i, sFileName});
i++;
}
}
finally
{
data.EndLoadData();
this.Cursor = Cursors.Default;
}
MessageBox.Show("done");
}
private void AddColumn(DataTable data, string name,
System.Type type, bool ro)
{
DataColumn col;
col = new DataColumn(name, type);
col.Caption = name;
col.ReadOnly = ro;
data.Columns.Add(col);
}
}
}
Thanks for you help. :)
-Markus_R