wofstream hFile(L"D://Res.xml",ios::app); // _SH_DENYRW is deny read and write
if (!hFile) // if the file could open, hFile is a handle, else is zero
{
cout << "write fail!" << endl;
cout << "access is denies,maybe the file is readonlys,or use deny read opened of other process." << endl;
}
else
{
hFile.imbue(std::locale("chs"));
hFile << NewXml.GetString() << std::endl;
cout << "write success!" << endl;
}
hFile.close(); // opened file need close.
}
catch(...)
{
wofstream hFile(L"D://RPT.txt",ios::app);
hFile.imbue(std::locale("chs"));
hFile << strFileName.GetString() << std::endl;
cout << "文件转化出错!" << endl;
}
//================中文路径===============
locale &loc=locale::global(locale(locale(),"",LC_CTYPE));
myXmlFile.Open(strFileName);
if(myXmlFile.GetRoot()->IsNull())
{
wofstream hFile(L"D://RPT.txt",ios::app);
hFile.imbue(std::locale("chs"));
hFile << strFileName.GetString() << std::endl;
cout << "文件转化出错!" << endl;
hFile.close();
return -1;
}
locale::global(loc);