T Ty Moffett Nov 3, 2003 #1 What is the best way to find the size of a folder (actually it's contents) on a disk?
H Herfried K. Wagner [MVP] Nov 3, 2003 #2 * "Ty Moffett said: What is the best way to find the size of a folder (actually it's contents) on a disk? Click to expand... Sample in C#: <http://www.google.com/groups?selm=JrXeg5sQCHA.1788@cpmsftngxa10> -- Herfried K. Wagner MVP · VB Classic, VB.NET <http://www.mvps.org/dotnet> <http://www.plig.net/nnq/nquote.html>
* "Ty Moffett said: What is the best way to find the size of a folder (actually it's contents) on a disk? Click to expand... Sample in C#: <http://www.google.com/groups?selm=JrXeg5sQCHA.1788@cpmsftngxa10> -- Herfried K. Wagner MVP · VB Classic, VB.NET <http://www.mvps.org/dotnet> <http://www.plig.net/nnq/nquote.html>
T Tom Leylan Nov 3, 2003 #3 Ty Moffett said: What is the best way to find the size of a folder (actually it's contents) on a disk? Click to expand... I converted the C# code... Private Function DirSize(ByVal path As String) As Long Dim sz As Long = 0 Dim d As DirectoryInfo = New DirectoryInfo(path) ' get file length Dim f As FileInfo For Each f In d.GetFiles() sz += f.Length Next ' recurse into directories Dim dx As DirectoryInfo For Each dx In d.GetDirectories() sz += DirSize(dx.FullName) Next Return sz End Function
Ty Moffett said: What is the best way to find the size of a folder (actually it's contents) on a disk? Click to expand... I converted the C# code... Private Function DirSize(ByVal path As String) As Long Dim sz As Long = 0 Dim d As DirectoryInfo = New DirectoryInfo(path) ' get file length Dim f As FileInfo For Each f In d.GetFiles() sz += f.Length Next ' recurse into directories Dim dx As DirectoryInfo For Each dx In d.GetDirectories() sz += DirSize(dx.FullName) Next Return sz End Function
H Herfried K. Wagner [MVP] Nov 3, 2003 #4 * "Tom Leylan said: I converted the C# code... Click to expand... Thank you for doing that! The next time this question is posted we have a solution written in VB.NET. -- Herfried K. Wagner MVP · VB Classic, VB.NET <http://www.mvps.org/dotnet> <http://www.plig.net/nnq/nquote.html>
* "Tom Leylan said: I converted the C# code... Click to expand... Thank you for doing that! The next time this question is posted we have a solution written in VB.NET. -- Herfried K. Wagner MVP · VB Classic, VB.NET <http://www.mvps.org/dotnet> <http://www.plig.net/nnq/nquote.html>
T Ty Moffett Nov 4, 2003 #5 Heh, just a I got it converted I noticed your post. At least I know I'm learning something. Thanks fellas. =)
Heh, just a I got it converted I noticed your post. At least I know I'm learning something. Thanks fellas. =)