Save filenames inside a directory to textbox
i have little question,
i want make program reads filenames inside selected folder. , after selecting folder saves filenames in (rich)textbox. select example folder contains files names: "piet" , "joop". after selecting folder saves names "piet" , "joop" textbox.
here code far:
using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms; using system.io; using system.collections; namespace trackreader { public partial class form1 : form { public form1() { initializecomponent(); } private void exittoolstripmenuitem_click(object sender, eventargs e) { this.close(); } private void infotoolstripmenuitem_click(object sender, eventargs e) { form2 form2 = new form2(); form2.show(); } private void howtousetoolstripmenuitem_click(object sender, eventargs e) { form3 form3 = new form3(); form3.show(); } private void button1_click(object sender, eventargs e) { folderbrowserdialog fbd = new folderbrowserdialog(); fbd.rootfolder = environment.specialfolder.mycomputer; if (fbd.showdialog() == system.windows.forms.dialogresult.ok) textbox2.text = fbd.selectedpath; } private void textbox1_textchanged(object sender, eventargs e) { } private void textbox3_textchanged(object sender, eventargs e) { } private void button2_click(object sender, eventargs e) { if (savefiledialog1.showdialog() == system.windows.forms.dialogresult.ok) { file.writealltext(savefiledialog1.filename, textbox1.text); } } private void button3_click(object sender, eventargs e) { if (openfiledialog1.showdialog() == system.windows.forms.dialogresult.ok) { textbox1.text = file.readalltext(textbox1.text); } } } }thank you!
try this
textbox2.text = string.join(", ", (from fn in system.io.directory.getfiles(fbd.selectedpath)
select system.io.path.getfilenamewithoutextension(fn).split('.')[0]).distinct().toarray());
muthukrishnan ramasamy
net4.rmkrishnan.net
use need, reduce global warming
Visual Studio Languages , .NET Framework > Visual C#
Comments
Post a Comment