Click here to Skip to main content
15,887,214 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Is CMap's PLookup thread safe ?? Pin
rahul.kulshreshtha23-Sep-11 1:35
rahul.kulshreshtha23-Sep-11 1:35 
Questionadding the image in Menu Pin
sarfaraznawaz22-Sep-11 20:01
sarfaraznawaz22-Sep-11 20:01 
AnswerRe: adding the image in Menu Pin
_Flaviu22-Sep-11 21:45
_Flaviu22-Sep-11 21:45 
AnswerRe: adding the image in Menu Pin
Richard MacCutchan23-Sep-11 0:01
mveRichard MacCutchan23-Sep-11 0:01 
QuestionDirectory Size Pin
john563222-Sep-11 17:06
john563222-Sep-11 17:06 
QuestionRe: Directory Size Pin
David Crow22-Sep-11 17:17
David Crow22-Sep-11 17:17 
AnswerRe: Directory Size Pin
john563222-Sep-11 17:41
john563222-Sep-11 17:41 
AnswerRe: How to get size of all files in a directory Pin
Software_Developer22-Sep-11 22:26
Software_Developer22-Sep-11 22:26 
This shows how to get the size of all the files in a folder,
and all its sub-folders on MS-Windows operating system.
It uses recursion to transverse all the directories, and return a 64-bit integer.

It was compiled with VC++ 2008 Express .


C++
#include <iostream>
#include <windows.h>
#include <string>
using namespace std;
 
 
__int64 TransverseDirectory(string path)
{
    WIN32_FIND_DATA data;
    __int64 size = 0;
    string fname = path + "\\*.*";
    HANDLE h = FindFirstFile(fname.c_str(),&data);
    if(h != INVALID_HANDLE_VALUE)
    {
        do {
            if( (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
            {
                // make sure we skip "." and "..".  Have to use strcmp here because
                // some file names can start with a dot, so just testing for the 
                // first dot is not suffient.
                if( strcmp(data.cFileName,".") != 0 &&strcmp(data.cFileName,"..") != 0)
                {
                    // We found a sub-directory, so get the files in it too
                    fname = path + "\\" + data.cFileName;
                    // recurrsion here!
                    size += TransverseDirectory(fname);
                }
 
            }
            else
            {
                LARGE_INTEGER sz;
                // All we want here is the file size.  Since file sizes can be larger
                // than 2 gig, the size is reported as two DWORD objects.  Below we
                // combine them to make one 64-bit integer.
                sz.LowPart = data.nFileSizeLow;
                sz.HighPart = data.nFileSizeHigh;
                size += sz.QuadPart;
 
            }
        }while( FindNextFile(h,&data) != 0);
        FindClose(h);
 
    }
    return size;
}
 
int main(int argc, char* argv[])
{
    __int64 size = 0;
    string path;
    size = TransverseDirectory("c:\\dvlp");
    cout << "\n\nDirectory Size = " << size << "\n";
    cin.ignore();
    return 0;
}

QuestionCode Signing Considerations Pin
Bram van Kampen22-Sep-11 13:39
Bram van Kampen22-Sep-11 13:39 
Questionuse of child CFrameWnd in Visual Studio 2008 [SOLVED] Pin
Jim Crafton22-Sep-11 4:22
Jim Crafton22-Sep-11 4:22 
QuestionPlease give me some idea 3D surface of revolution Pin
appollosputnik22-Sep-11 4:17
appollosputnik22-Sep-11 4:17 
AnswerRe: Please give me some idea 3D surface of revolution Pin
Stefan_Lang22-Sep-11 22:39
Stefan_Lang22-Sep-11 22:39 
QuestionHow to free the memory if memory is allocation using memset Pin
hema_soft21-Sep-11 23:05
hema_soft21-Sep-11 23:05 
AnswerRe: How to free the memory if memory is allocation using memset PinPopular
Niklas L21-Sep-11 23:12
Niklas L21-Sep-11 23:12 
AnswerRe: How to free the memory if memory is allocation using memset Pin
CPallini21-Sep-11 23:49
mveCPallini21-Sep-11 23:49 
AnswerRe: You can use the function - free() after first calling malloc() Pin
Software_Developer21-Sep-11 23:54
Software_Developer21-Sep-11 23:54 
AnswerRe: How to free the memory if memory is allocation using memset Pin
Erudite_Eric22-Sep-11 2:58
Erudite_Eric22-Sep-11 2:58 
Questionc++ objects, I don't get it - IIS ADSI object Pin
jkirkerx21-Sep-11 18:57
professionaljkirkerx21-Sep-11 18:57 
AnswerRe: c++ objects, I don't get it - IIS ADSI object Pin
XTAL25621-Sep-11 21:04
XTAL25621-Sep-11 21:04 
AnswerRe: c++ objects, I don't get it - IIS ADSI object Pin
Jim Crafton22-Sep-11 4:27
Jim Crafton22-Sep-11 4:27 
GeneralRe: c++ objects, I don't get it - IIS ADSI object Pin
jkirkerx22-Sep-11 6:17
professionaljkirkerx22-Sep-11 6:17 
GeneralRe: c++ objects, I don't get it - IIS ADSI object Pin
Jim Crafton22-Sep-11 6:24
Jim Crafton22-Sep-11 6:24 
GeneralRe: c++ objects, I don't get it - IIS ADSI object Pin
jkirkerx22-Sep-11 6:52
professionaljkirkerx22-Sep-11 6:52 
Questionlanguage problem in C .. Pin
gateway2321-Sep-11 0:52
gateway2321-Sep-11 0:52 
AnswerRe: language problem in C .. Pin
Stefan_Lang21-Sep-11 1:39
Stefan_Lang21-Sep-11 1:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.