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

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -