我的應用遇到了ramdon錯誤。生成新文件時,txt文件訪問被拒絕,並且其大小爲0K。CFile複製方法修復被拒絕的文件訪問問題
我只想複製現有文件並在關閉當前文件後重命名它。
任何人都可以給我一種方法來複制文件?謝謝。
我的代碼片段如下。
ofstream m_LogFile;
CFile logcfile;
if(dwLength > 1024*1024*10)
{
string fileDate = status.m_mtime.Format("%Y%m%d%H%M%S");
string modulePath = Util::GetModulePath();
string fileNewName(modulePath);
fileNewName += "mytextlog" + fileDate + ".txt";
m_LogFile.close();
// I want to insert CFile copy method before rename it.
logcfile.Rename(m_sLogFileName.c_str(), fileNewName.c_str());
m_LogFile.open(m_sLogFileName.c_str(), ios::out | ios::app);
_findfile(modulePath.c_str());
}
我假設我的應用程序錯誤是由上面的代碼引起的。