Click here to Skip to main content
15,617,203 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?
Tarun.K.S 16-Nov-10 0:09am    
use the DriveInfo class and directory class

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.
Share this answer
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.
Share this answer
drummerboy0511 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)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900