Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Folder Size

Folder Size

Scheduled Pinned Locked Moved Visual Basic
csharphelpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Ramaza
    wrote on last edited by
    #1

    I'm a vb.net noob who needs some help. Is there a way to get the size of a specified folder? I'm using this code to get all sub-directories of a specified folder and would like to also retrive the folder size of each. Dim myPath As String = "C:\test" Dim myDirectory As System.IO.Directory Dim mySubDirectory As String Dim myDirectorySize As String If myDirectory.Exists(myPath) Then For Each mySubDirectory In myDirectory.GetDirectories(myPath) MsgBox(mySubDirectory) Next End If Any ideas?

    C 2 Replies Last reply
    0
    • R Ramaza

      I'm a vb.net noob who needs some help. Is there a way to get the size of a specified folder? I'm using this code to get all sub-directories of a specified folder and would like to also retrive the folder size of each. Dim myPath As String = "C:\test" Dim myDirectory As System.IO.Directory Dim mySubDirectory As String Dim myDirectorySize As String If myDirectory.Exists(myPath) Then For Each mySubDirectory In myDirectory.GetDirectories(myPath) MsgBox(mySubDirectory) Next End If Any ideas?

      C Offline
      C Offline
      Christian Eriksen
      wrote on last edited by
      #2

      Private Function DirectoryList(ByVal Name As String) As Int64   Dim Folder As New DirectoryInfo(Name)   Dim SubFolder As DirectoryInfo   Dim File As FileInfo   Dim Size As Int64 = 0
        'Get the size of all files in folder   For Each File In Folder.GetFiles()     Size += Files.Length   Next
        'Get the size of all subfolders in folder   For Each SubFolder In Folder.GetDirectories()     Size += DirectoryList(SubFolders.FullName)   Next
        MsgBox(Name & " containes " & Size & " bytes")
        Return Size End Function

      1 Reply Last reply
      0
      • R Ramaza

        I'm a vb.net noob who needs some help. Is there a way to get the size of a specified folder? I'm using this code to get all sub-directories of a specified folder and would like to also retrive the folder size of each. Dim myPath As String = "C:\test" Dim myDirectory As System.IO.Directory Dim mySubDirectory As String Dim myDirectorySize As String If myDirectory.Exists(myPath) Then For Each mySubDirectory In myDirectory.GetDirectories(myPath) MsgBox(mySubDirectory) Next End If Any ideas?

        C Offline
        C Offline
        Christian Eriksen
        wrote on last edited by
        #3

        Sorry, I was a little quick there... A simple sollution would be to make a recursive function, like the one in the example in the preceding thread. The topmost folder will be displayed last...

        R 1 Reply Last reply
        0
        • C Christian Eriksen

          Sorry, I was a little quick there... A simple sollution would be to make a recursive function, like the one in the example in the preceding thread. The topmost folder will be displayed last...

          R Offline
          R Offline
          Ramaza
          wrote on last edited by
          #4

          Thanks, I appreciate the help.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups