C# directory search (the number) -


this question has answer here:

private int dreturn, freturn = 0;  public maker() {     initializecomponent(); }  private void button1_click(object sender, eventargs e) {     if (fd.showdialog() != dialogresult.ok) { return; }     listview1.items.clear();     dreturn = 0;     freturn = 0;     textbox1.text = fd.selectedpath;      scanner scanner = new scanner();      scanner.show();     fscan(fd.selectedpath);     dscan(fd.selectedpath);     scanner.close();      messagebox.show("file : " + freturn + ", folder : " + dreturn, "information", messageboxbuttons.ok, messageboxicon.information); }  private int dscan(string path) {     try     {         foreach (string d in directory.getdirectories(path))         {             dreturn = dreturn + 1;             dscan(d);             application.doevents();         }     }      catch(exception)     {         listviewitem access = new listviewitem(path);         listview1.items.add(access);     }      return dreturn; } 

i want know number of folders in selected path. made recursive function above. number of folders not same pc property view. please me... fine when path small, problem arises when large.


thanks comment. sorry, not enough description. show image.

enter image description here

like program search more number of folder.

maybe have hidden folders (c# - list of files excluding hidden) ?

by way, getdirectories can return subdirectories : https://msdn.microsoft.com/fr-fr/library/ms143314(v=vs.110).aspx :

directory.getdirectories(path, "*", searchoption.alldirectories); 

if still have problems, try debugging see differences.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -