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
Post a Comment