Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6882613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:16:32+00:00 2026-05-27T05:16:32+00:00

I’m working on this app to gather some file/folder usage data. The goal is

  • 0

I’m working on this app to gather some file/folder usage data. The goal is to have my object know the size of its files and children folders; at every point in the tree.

My problem is; after getting the directory structure into my objects, I’m perplexed at how to get the subtotals in there.

Could I actually add the totals in when creating the trees? Or do I have to step through the tree in reverse (which seems especially confusing…)

I’m a novice with no computer science education; I’m sure the answer would be out there if I knew the right terminology to Google.

My classes are currnetly a bit of a mess, they’ve still got some half formed ideas there…

Imports System.IO
Public Class Form1
    Public Class mrFURDirectory
        Public Property Name As String
        Public Property FileSize As Long = 0
        Public Property FileCount As Long = 0
        Public Property DirSize As Long = 0
        Public Property DirCount As Long = 0
        Public Property Parent As mrFURDirectory
        Public Property Children As New List(Of mrFURDirectory)
        Public Property PercentOfParent As Short = 0
        Public Property DirChecked As Boolean = False

        Public Sub New(ByVal Name As String)
            Me.Name = Name
        End Sub
    End Class

    Public Class mrBaseFURDirectory
        Inherits mrFURDirectory
        Property RootPath As String

        Sub New(ByVal Name As String, ByVal RootPath As String)
            MyBase.New(Name = Name)
            Me.RootPath = RootPath
        End Sub

    End Class

    Dim BaseDirectory As New mrBaseFURDirectory("A:\", "a:\") 'RAM disk full files/folders

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'setup IO
        Dim IOBaseDirectory As IO.DirectoryInfo
        IOBaseDirectory = New IO.DirectoryInfo(BaseDirectory.RootPath)

        'go get 'em tiger!
        GatherChildDirectoryStats(IOBaseDirectory, BaseDirectory)

        MsgBox("Done.")
    End Sub

    Public Sub GatherChildDirectoryStats(ByVal IODirectory As IO.DirectoryInfo, ByVal FURDirectory As mrFURDirectory)

        'get the file count and total size of files in this directory
        For Each aFile As IO.FileInfo In IODirectory.GetFiles
            FURDirectory.FileSize += aFile.Length
            FURDirectory.FileCount += 1
        Next

        For Each Directory As IO.DirectoryInfo In IODirectory.GetDirectories
            'DirCount likely redundant..
            FURDirectory.DirCount += 1

            'if we're in here, we need another child, make one
            Dim NewChildDir As mrFURDirectory
            'attach it to the parent
            FURDirectory.Children.Add(New mrFURDirectory(Directory.Name))
            'reference the child
            NewChildDir = FURDirectory.Children(FURDirectory.Children.Count - 1)
            'tell the child who the parent is
            NewChildDir.Parent = FURDirectory

            'recurse into sub again
            GatherChildDirectoryStats(Directory, NewChildDir)
        Next

    End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:16:32+00:00Added an answer on May 27, 2026 at 5:16 am

    After adding up all the file sizes in each node you are calling the subnodes to do the same. After this call returns add this:

    'recurse into sub again
    GatherChildDirectoryStats(Directory, NewChildDir)
    
    'add child sums to this node    
    FURDirectory.DirSize += NewChildDir.FileSize + NewChildDir.DirSize
    

    So the last node sums up its files, returns and the sums are added to the n-1 node etc. Recursion rocks!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some data like this: 1 2 3 4 5 9 2 6
I have just tried to save a simple *.rtf file with some websites and
I have a reasonable size flat file database of text documents mostly saved in
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.