Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB9.0 VB.NET
In this line of code, I get the amount of files in the user's cookies folder and the size of the folder, and display them in a label:
 
Label1.Text = (" - " + CStr(cookiecounter.Count) + " cookies (" + (cookiefoldersize / 1000 / 1000).ToString("0.00") + " MB)")
 
It doesn't give the results that I want... it shows the total size of the folder. I want it to show the size of the total amount of *.txt files in the folder. Is there a way to do this?
Posted 15-Nov-10 13:22pm
Comments
Tarun.K.S at 16-Nov-10 0:09am
   
use the DriveInfo class and directory class
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

My bad, it's actually DirectoryInfo and it's GetFiles method.
 
    Dim rootFolder As DirectoryInfo("C:\somePath")
    Dim txtFiles() As FileInfo
 
    txtFiles = rootFolder.GetFiles("*.txt")
 
Then it's a simple matter of enumerating over the txtFiles collection and adding up the Length properties of each FileInfo object.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You'll have to use the Directory class to get the list of .TXT files in the users cookie folder (first you have to determine what the path to that folder is, obviously!) then you can just add up all the sizes.
  Permalink  
Comments
drummerboy0511 at 17-Nov-10 15:41pm
   
I'm not entirely sure how to do this...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 275
1 DamithSL 265
2 CPallini 235
3 Maciej Los 185
4 George Jonsson 170
0 OriginalGriff 5,305
1 DamithSL 4,382
2 Maciej Los 3,760
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,901


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 17 Nov 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100