I found these solutions via Google search:
A pure Win32 C++ example can be found here:
How to find the size of all files, located inside a folder[
^]
If you enable .NET Framework managed code in your C++ application, you can use this:
Scan the Directory / Files (Calculating the size)[
^]. It does require recursion.
You can enable Managed C++ easily within your Native C++ project. If you are planning to use .NET System.IO.Directory, you can call in your native C++ project using the following setting.
Enable the "/clr" switch in Project Properties -> General -> Common Language Run time Support).
Now, your project will support .NET Framework classes. You can directly use managed C++ code in your programming.
Note:
I don't think there is any way to do it without a recursive scan. Think about how it would slow down your computer if every time you added something to a file, Windows had to update all the directory nodes above where your file was located.