#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#include <tchar.h>
#include<windows.h>
using namespace std; LPWSTR StringToLPWSTR(string s)
{
const char * szString = s.c_str();
int dwLen = strlen(szString) + ;
int nwLen = MultiByteToWideChar(CP_ACP, , szString, dwLen, NULL, );//算出合适的长度
LPWSTR lpszPath = new WCHAR[dwLen];
MultiByteToWideChar(CP_ACP, , szString, dwLen, lpszPath, nwLen);
return lpszPath; } int _tmain(int argc, _TCHAR* argv[])
{ string file_dir = "d:\\中国1\\中国2\\中国3\\中国4"; string file_name = "";
string file_part_path = file_dir;
string file_path; int symbol_index = ;
while (symbol_index != -)
{
symbol_index = file_part_path.find("\\"); file_name = file_part_path.substr(, symbol_index + );
file_part_path = file_part_path.substr(symbol_index + ); file_name = symbol_index == - ? file_part_path : file_name;
file_path += file_name;
LPWSTR lp_dest_file_dir = StringToLPWSTR(file_path);
CreateDirectoryW(lp_dest_file_dir, NULL); cout << file_path << endl; }
system("pause");
return ;
}