473,395 Members | 1,558 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Get folder size

134 100+
how would i get the size of a folder in c++?

and how do you assign it to a variable (string, int, whatever)


thanks
May 13 '07 #1
5 5228
AdrianH
1,251 Expert 1GB
how would i get the size of a folder in c++?

and how do you assign it to a variable (string, int, whatever)


thanks
AFAIK, you get the folder size by finding the size of each file within the folder. I am not aware of any file system that keeps that information available. And even if there was one, that would not work for the other file systems.

Unless you are literally asking for the size of the folder (how many bytes the folder is to hold the names, dates, and other housekeeping stuff). In that case, I'm not sure, but I think it can be done.


Adrian
May 13 '07 #2
lumpybanana247
134 100+
AFAIK, you get the folder size by finding the size of each file within the folder. I am not aware of any file system that keeps that information available. And even if there was one, that would not work for the other file systems.

Unless you are literally asking for the size of the folder (how many bytes the folder is to hold the names, dates, and other housekeeping stuff). In that case, I'm not sure, but I think it can be done.


Adrian

alright, thanks
(I'm done with it)
but, if you ever somehow stumble across the answer, let me kno.

later
May 13 '07 #3
AdrianH
1,251 Expert 1GB
alright, thanks
(I'm done with it)
but, if you ever somehow stumble across the answer, let me kno.

later
I'm sorry, I thought that I just gave you the answer.


Adrian
May 13 '07 #4
lumpybanana247
134 100+
I'm sorry, I thought that I just gave you the answer.


Adrian
Well, it helps, but i would have needed somthing to get the size of the whole folder instead of all files in it. (because for instance the cookies folder, i cant get the size of each cookie cuz i dont know the name of the files)
thanks though
May 13 '07 #5
AdrianH
1,251 Expert 1GB
Well, it helps, but i would have needed somthing to get the size of the whole folder instead of all files in it. (because for instance the cookies folder, i cant get the size of each cookie cuz i dont know the name of the files)
thanks though
Huh? You just scan the directory. Either use the POSIX functions opendir(), readdir(), closedir() or the OS specific equivilants.

See here for more info on the POSIX calls.

Boost also has a filesystem library which is also quite helpful.

Good luck,


Adrian
May 13 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Chris | last post by:
Hi, Not sure if this is the right forum, but hopefully someone can help me. I am creating something for our intranet and i want to list the files and folders of a directory, i found some code...
8
by: Ty Moffett | last post by:
What is the best way to find the size of a folder (actually it's contents) on a disk?
2
by: John Regan | last post by:
Hello All I am trying to find the owner of a file or folder on our network (Windows 2000 Server) using VB.Net and/or API. so I can search for Folders that don't follow our company's specified...
12
by: grouped2000 | last post by:
g'day group, I need some code that will give me the total size of a folder. In the MSDN I've found some code, but I cannot figure out how to use this code at all ... I am quite new to .NET, I...
6
by: Caleb Hattingh | last post by:
Hi everyone Unless you have a nice tool handy, calculating many folder sizes for clearing disk space can be a click-fest nightmare. Looking around, I found Baobab (gui tool); the "du"...
3
by: TyBreaker | last post by:
I have a vbscript which returns the folder size of any folder instantly by referring to Folder.Size. I don't need any iteration or recursion through the subfolders, adding together individual file...
9
by: Eugene Anthony | last post by:
How do I calculate the size of a folder? Also how do I count the number of images stored in a folder? Eugene Anthony *** Sent via Developersdex http://www.developersdex.com ***
4
by: shuisheng | last post by:
Dear All, I'd like to build a structure similar to the folder tree which 1. Has a root. 2. Nodes can be folder or files. 3. Folder can contain folders and files. 4. Name of folders and files...
5
by: bharathreddy | last post by:
How to find the size of a folder using C# code? step1: Here take the folder which u want to find the size, then pass that folder to the recursive function name FolderSize!. DirectoryInfo...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.