The example in this chapter uses the techniques you have learned in this chapter to list all the files in a folder, and subfolders, in order of file size, giving a listing of the filenames and their sizes. The example is the equivalent of typing the following at the command line:
dir /b /s /os /a-d folder
Here, folder is the folder you are listing. The /s option recurses, /a-d removes folders from the list, and /os orders by size. The problem is that without the /b option we get information about each folder, but using it removes the file size in the list. We want a list of filenames (and their paths), their size, ordered by the smallest first.
Start by creating a new folder for this chapter (Chapter_05) under the Beginning_C++ folder. In Visual C++ create a new C++ source file and save it as files.cpp under this new folder. The example will use basic...