1 //多字符集 2 3 #include "stdafx.h" 4 #include <Windows.h> 5 #include <iostream> 6 7 using namespace std; 8 9 BOOL MakeSureDirectoryPathExists(char* DirectoryFullPath); 10 11 int main() 12 { 13 char* DirectoryFullPath = "E:\这个是我们自己创建的多层目录\DemoSucess\";//要在最后加上那个双斜杠,否则无法创建最后一层 14 MakeSureDirectoryPathExists(DirectoryFullPath); 15 return 0; 16 } 17 18 BOOL MakeSureDirectoryPathExists(char* DirectoryFullPath) 19 { 20 char* Travel = NULL; 21 char* BufferData = NULL; 22 DWORD DirectoryAttributes; 23 24 BufferData = (char*)malloc(sizeof(char)*(strlen(DirectoryFullPath) + 1)); 25 26 if (BufferData == NULL) 27 { 28 return FALSE; 29 } 30 31 strcpy(BufferData, DirectoryFullPath); 32 33 Travel = BufferData; 34 35 36 if (*(Travel + 1) == ':') 37 { 38 Travel++; 39 Travel++; 40 if (*Travel && (*Travel == '\')) 41 { 42 Travel++; 43 } 44 } 45 while (*Travel) //D:Hello\WorldShit 46 { 47 if (*Travel == '\') 48 { 49 *Travel = '