I wanna get all multiple files in listview in c# like "ppt,docx,and txxt but i get only one at a time" -


it work not complete need.

private void button2_click(object sender, eventargs e) {     listview1.items.clear();     if (textbox1.text != "")     {         list<string> files = new list<string>();         files = directory.getfiles(textbox1.text, "*.txt,*.ppt").tolist();         progressbar1.maximum = files.count;         progressbar1.value = 0;         listviewitem it;         foreach (var file in files)         {             = new listviewitem(file.tostring());             it.subitems.add(system.io.path.getfilename(file.tostring()));             it.subitems.add(system.io.path.getextension(file.tostring()));             listview1.items.add(it);             progressbar1.increment(1);         }     }     else         messagebox.show("select directory first"); } 

getfiles doesnt take multiple extensions

your : files = directory.getfiles(textbox1.text, "*.txt,*.ppt").tolist();

would come

string[] extensions= new string[] {"txt","ppt"};  foreach (string extension in extensions)    files.addrange(directory.getfiles(textbox1.text, "*."+extension)); 

this give results.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -