Click here to Skip to main content
13,201,452 members (73,816 online)
Rate this:
Please Sign up or sign in to vote.
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?
Posted 15-Nov-10 12:22pm
Tarun.K.S 16-Nov-10 0:09am
use the DriveInfo class and directory class
Rate this: bad
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.
Rate this: bad
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.
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.171020.1 | Last Updated 17 Nov 2010
Copyright © CodeProject, 1999-2017
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