An alternative to iterating a folder's contents to get the size is to use the scripting object,
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
to your project.
As its not needed, you'll likely need to comment out the
class and its methods.
Now we just have to create the object and call its
if (fso.CreateDispatch(_T("Scripting.FileSystemObject")) == TRUE)
folder = fso.GetFolder(_T("C:\\Windows\\System32"));
_variant_t vtSize = folder.GetSize();