Hi,
you are adding the row, then setting the row by name [FileName], which hasn't been added until the next line.
so if you change your code as follow:
DataRow dr = dt.NewRow();
dt.Rows.Add(dr);
string filenameWithoutPath = Path.GetFileName(FileName);
dr["FileName"] = filenameWithoutPath;
======================= Correction =========================================
To add the items in the combobox inside the drop down menu
public void SetFileNames()
{
string[] Filelistarray = Directory.GetFiles(@"D:\Projects\VS_Test_Projects\WpfApplication1\InfragisticsTest\bin\Debug", "*.txt");
List<string> fileNames = new List<string>();
foreach (string FileName in Filelistarray)
{
string filenameWithoutPath = Path.GetFileName(FileName);
fileNames.Add(filenameWithoutPath);
}
toolStripComboBox2.Items.AddRange(fileNames.ToArray());
}
Regards
Jegan