ofstream的奇怪问题
我在头文件中定义
std::ofstream m_osOutput;
在函数中这样写的,
void CServerLog::CreateLogFile(std::string strLogName)
{
m_osOutput.open(strLogName.c_str(), std::ios_base::app);
SetFileAttributes(strLogName.c_str(),FILE_ATTRIBUTE_NORMAL);
if (!m_osOutput)
{
int err = GetLastError();
}
}
strlongName ="d:\\runlog.txt"
我要实现的功能是:当runlog.txt不存在时创建并在尾部写日志,
如果存在的话直接在尾部写日志。
现在出的问题是:当runlog.txt文件存在时候,,err捕捉到的是183(当文件已存在时,无法创建该文件。)
如果runlog.txt不存在,err是5(拒绝访问。 )
有没有牛人帮忙分析下啊,,