C
C#2y ago
Itamar

❔ Hello I need some help with a recursion dirs & files tree in windows forms

I have the following function I can get the length (size of the current folder and show it ) but I need for each dir to enter the sub dir and also calc the size of them and not sure how to do it (Calc the files using length property), so for every dir I need to calculate the whole dirs & files size sitting under it using rec
13 Replies
Itamar
ItamarOP2y ago
any help or maybe some guide to help me understand rec better is much appreciated
Florian Voß
Florian Voß2y ago
don't reinvent the wheel, use Directory.EnumerateFiles() and Directory.EnumerateDirectories() from System.IO passing SearchOptions.AllDirectories to it
Itamar
ItamarOP2y ago
I have no idea how to use it 😦 its hw for school but ill try to check thoose 2 now
Florian Voß
Florian Voß2y ago
Work with files and directories in a .NET app - Training
Learn how to use .NET, C#, and System.IO to work with directories, paths, files, and the file system.
Florian Voß
Florian Voß2y ago
take this 45 minutes estimated interactive course will teach you everything about working with files and directories you gotta know in .net
Itamar
ItamarOP2y ago
sweet nice is it free
Florian Voß
Florian Voß2y ago
sure
Itamar
ItamarOP2y ago
thanks ill try it now
Florian Voß
Florian Voß2y ago
all docs.microsoft.com or learn.microsoft.com ressources arre free afaik
Itamar
ItamarOP2y ago
using the Directory Enumrate Files I can get he size of sub folders?
Florian Voß
Florian Voß2y ago
if all you care about is the whole folders' sizes then Directory.EnumerateDirectories should be enough tho btw if your school hw includes creating the recursive algorithm yourself by hand, then you cant use my suggested approach but at least you know how its done properly after this course 😄
Itamar
ItamarOP2y ago
yes that's most important brain burnning ...........
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server