多階層フォルダを関数1つで作成する方法
CreateDirectoryだと1発で多階層フォルダを作れない。
例えば fruits/apple/red のようなフォルダを作成したい場合、
CreateDirectoryを使用する場合は、fruits、apple、red と1つずつフォルダを作っていく必要がある。
MakeSureDirectoryPathExistsを使用すれば1度に作ってくれて便利なのです。
関数
BOOL IMAGEAPI MakeSureDirectoryPathExists(
[in] PCSTR DirPath
);
使用例
#include <imagehlp.h> #pragma comment(lib, "imagehlp.lib") auto ret = MakeSureDirectoryPathExists("D:\\fruits\\apple\\red\\")
パスの最後は「\\」で終わる必要があるので注意。
既に作成されていてもエラーになりません。