Sixem

.NET Get Amount Of Files And Size Of A Folder

Jul 30th, 2013
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.55 KB | None | 0 0
  1.         Dim Based_Path As String = CStr("C:\Some\Random\Path")
  2.         Dim KB_Files As Integer = CInt(System.IO.Directory.GetFiles(Based_Path).Length())
  3.         KB_Size = (From strFile In My.Computer.FileSystem.GetFiles(Based_Path, _
  4.         FileIO.SearchOption.SearchAllSubDirectories) _
  5.         Select New System.IO.FileInfo(strFile).Length).Sum()
  6.         Dim i As New StringBuilder
  7.         i.AppendLine(String.Format("{0} Files", KB_Files))
  8.         i.AppendLine(String.Format("{0} GB", KB_To_GB(KB_Size)))
  9.         Virtual_Stats.Text = CStr(i.ToString)
Advertisement
Add Comment
Please, Sign In to add comment