LPCWSTR strName = L"shuishi张三";
LPCWSTR appName = L"StudnetInfo";
//判断文件夹是否存在
int state = _access( File_Path, ABI::Windows::Devices::Custom::IOControlAccessMode::IOControlAccessMode_Any);
//Windows::Devices::Custom::
bool isFileExist;
if (state != 0)
{
//不存在这个文件夹, 需要重新创建文件夹
int dirSuccess = mkdir(File_Path);
if (dirSuccess != 0)
{
assert(false, "the dir can't create");
}
}
else
{
//直接读取即可
}
//拼接字符串
char strFile[1024];
sprintf(strFile, "%s\\%s", File_Path, File_Name);
LPCWSTR convStr = (LPCWSTR)strFile;
std::ofstream fout(strFile);
if (fout)
{
std::cout << "创建成功" << std::endl;
std::cout << File_Path << std::endl;
}
else
{
std::cout << "创建失败" << std::endl;
std::cout << File_Path << std::endl;
}
LPSTR lpStr = (LPSTR)(LPCSTR)(strFile);
LPCWSTR lpCW = A2WBSTR(lpStr);
LPCWSTR appName = L"StudnetInfo";
//判断文件夹是否存在
int state = _access( File_Path, ABI::Windows::Devices::Custom::IOControlAccessMode::IOControlAccessMode_Any);
//Windows::Devices::Custom::
bool isFileExist;
if (state != 0)
{
//不存在这个文件夹, 需要重新创建文件夹
int dirSuccess = mkdir(File_Path);
if (dirSuccess != 0)
{
assert(false, "the dir can't create");
}
}
else
{
//直接读取即可
}
//拼接字符串
char strFile[1024];
sprintf(strFile, "%s\\%s", File_Path, File_Name);
LPCWSTR convStr = (LPCWSTR)strFile;
std::ofstream fout(strFile);
if (fout)
{
std::cout << "创建成功" << std::endl;
std::cout << File_Path << std::endl;
}
else
{
std::cout << "创建失败" << std::endl;
std::cout << File_Path << std::endl;
}
LPSTR lpStr = (LPSTR)(LPCSTR)(strFile);
LPCWSTR lpCW = A2WBSTR(lpStr);
int ptr = WritePrivateProfileString(L"StudnetInfo", L"Name", strName, lpCW);
看来还需要多学习啊, windows 中的字符及编码还是没太摸清楚