// What directory are the files in?...
DirectoryInfo dinfo = new DirectoryInfo(@"C:TestDirectory");
// What type of file do we want?...
FileInfo[] Files = dinfo.GetFiles("*.txt");
// Iterate through each file, displaying only the name inside the listbox...
foreach( FileInfo file in Files )
{
listbox1.Items.Add(file.Name);
}
// A statement, followed by a smiley face...
That oughta do it. ;o)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…