c# - How to list text files in the selected directory in a listbox? -
how can list text files in directory (c:\users\ece\documents\testings) in listbox of winform(windows application)?
// directory files in?...
directoryinfo dinfo = new directoryinfo(@"c:\testdirectory");
// type of file want?...
fileinfo[] files = dinfo.getfiles("*.txt");
// iterate through each file, displaying name inside listbox...
foreach( fileinfo file in files ) { listbox1.items.add(file.name); }
// statement, followed smiley face... oughta it. ;o)
Comments
Post a Comment