Click here to Skip to main content
Click here to Skip to main content

What size is this folder?

, 12 May 2010
Rate this:
Please Sign up or sign in to vote.
An alternative to iterating a folder's contents to get the size is to use the scripting object, FileSystemObject.Using ClassWizard (Ctrl+W), the first thing you'll need to do is add the classes contained in the Script Runtime engine (scrrun.dll). This will add scrrun.cpp and scrrun.h to...
An alternative to iterating a folder's contents to get the size is to use the scripting object, FileSystemObject.
 
Using ClassWizard (Ctrl+W), the first thing you'll need to do is add the classes contained in the Script Runtime engine (scrrun.dll). This will add scrrun.cpp and scrrun.h to your project.
 
As its not needed, you'll likely need to comment out the IDrive class and its methods.
 
Now we just have to create the object and call its GetSize() method, like:
 
CoInitialize(NULL);
 
IFileSystem fso;
if (fso.CreateDispatch(_T("Scripting.FileSystemObject")) == TRUE)
{
    IFolder folder;
    folder = fso.GetFolder(_T("C:\\Windows\\System32"));
            
    _variant_t vtSize = folder.GetSize();
}
Enjoy!

License

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

About the Author

DavidCrow
Software Developer (Senior) Pinnacle Business Systems
United States United States

The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.
 
HTTP 404 - File not found
Internet Information Services

Comments and Discussions

 
GeneralHI,friend DavidCrow, what's IDriver class? Pinmemberupsonn13-May-10 21:54 

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

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

| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 12 May 2010
Article Copyright 2010 by DavidCrow
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid