Folder utilities






1.60/5 (16 votes)
Jan 24, 2005

71234

1208
Folder utilities such as creating, removing, copying folders and getting folder's space.
Introduction
The CreateDirectory
WIN32 API lets us create a folder. However, this function will succeed only if the parent folder exists. For example, creating a folder C:\AA\BB\CC\DD succeeds only if the parent folder C:\AA\BB\CC exists. Thus, CFolderUtils::CreateFolder
solves that problem by creating the parent folders and then the specified folder itself.
The DeleteDirectory
WIN32 API will fail to delete a folder as long there are sub-folders for that one. Thus, CFolderUtils::RemoveFolder
solves that problem by removing recursively the sub-folders and after that the specified folder.
CFolderUtils::GetSpace
recursively calculates a folder size.
CFolderUtils::CopyFolder
uses SHFileOperation
for copying a folder along with its sub-folders.
Whole four functions are implemented in FolderUtils.h as static functions to CFolderUtils
.
Example
#include "FolderUtils.h" void main() { CFolderUtils::CreateFolder("C:\\AA\\BB\\CC\\DD"); int Size = CFolderUtils::GetSize("C:\\AA"); }
History
- 1-Feb-2005 - Fixed a bug in
CreateFolder
function. - 2-Feb-2005 - Fixed a bug in
GetSpace
that discarded folders that begin with "." and add a UNICODE support inRemoveFolder
.