目的:實(shí)現(xiàn)用CreateDirectory創(chuàng)建多級(jí)目錄
成都創(chuàng)新互聯(lián)主營梅縣網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,重慶App定制開發(fā),梅縣h5小程序設(shè)計(jì)搭建,梅縣網(wǎng)站營銷推廣歡迎梅縣等地區(qū)企業(yè)咨詢
1.引入靜態(tài)庫
#include "shlwapi.h"
#pragma comment(lib,"shlwapi.lib")
2.函數(shù)
const wchar_t* wcstrrchr(const wchar_t* str, const wchar_t wc)
{
const wchar_t* pwc = NULL;
for (int i=wcslen(str)-1;i>=0;i--)
{
if (str[i] == wc)
{
pwc = str + i;
break;
}
}
return pwc;
}
bool createMultiDir(const wchar_t* path)
{
if (path == NULL) return false;
const wchar_t* pwcStrrchr = wcstrrchr(path,L'\\');
if (!pwcStrrchr) return false;
if (PathIsDirectory(path)) return true;
wchar_t wsSubPath[MAX_PATH] = {};
memset(wsSubPath,0,sizeof(wsSubPath));
for (int i=0; i
3.調(diào)用案例
createMultiDir(L"d:\\whish\\test\\好孩子\\寶馬\\測(cè)試.txt"); //絕對(duì)路徑
createMultiDir(L".\\whish\\test\\好孩子\\寶馬\\測(cè)試.txt");//相對(duì)路徑