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 -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -