c# - Counting the total XML-files in a directory -
im trying write program counts total amounts of xml-files in directory , subdirectories. here how tried:
namespace jobbuppgift1 { public partial class form1 : form { public form1() { initializecomponent(); } string path1 = "c:\\jobbuppg"; private void textbox1_textchanged(object sender, eventargs e) { int filecount = directory.getfiles(path1, "*.xml", searchoption.alldirectories).length; textbox1.text = filecount.tostring(); } } } i no error, nothing happens.
need add slash path1 otherwise "j" being escaped or "@" works too
namespace jobbuppgift1 { public partial class form1 : form { public form1() { initializecomponent(); } string path1 = "c:\\jobbuppg";//this or line below string path1 = @"c:\jobbuppg";//this or line above private void textbox1_textchanged(object sender, eventargs e) { int filecount = directory.getfiles(path1, "*.xml", searchoption.alldirectories).length; textbox1.text = filecount.tostring(); } } }
Comments
Post a Comment