Hi,
There is no direct way to get the size of a directory. In msdn there is a
sample that shows how to get the size of a directory by adding the size of
all the files in a directory. Here is the URL
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemiodirectoryclasstopic.asp
Here is the sample
The following example calculates the size of a directory
' and its subdirectories, if any, and displays the total size
' in bytes.
Imports System
Imports System.IO
Imports Microsoft.VisualBasic
Public Class ShowDirSize
Public Shared Function DirSize(ByVal d As DirectoryInfo) As Long
Dim Size As Long = 0
' Add file sizes.
Dim fis As FileInfo() = d.GetFiles()
Dim fi As FileInfo
For Each fi In fis
Size += fi.Length
Next fi
' Add subdirectory sizes.
Dim dis As DirectoryInfo() = d.GetDirectories()
Dim di As DirectoryInfo
For Each di In dis
Size += DirSize(di)
Next di
Return Size
End Function 'DirSize
Public Overloads Shared Sub Main(ByVal args() As String)
If args.Length <> 1 Then
Console.WriteLine("You must provide a directory argument at the
command line.")
Else
Dim d As New DirectoryInfo(args(0))
Console.WriteLine("The size of {0} and its subdirectories is
{1} bytes.", d, DirSize(d))
End If
End Sub 'Main
End Class 'ShowDirSize
Anand Balasubramanian
Microsoft, Visual Basic .NET
This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only. Thanks