私のアプリはramdonエラーに遭遇しました。新しいファイルが生成され、そのサイズが0Kのときにtxtファイルへのアクセスが拒否されました。ファイルアクセス拒否の問題を解決するための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());
}
私は上記のコードによってアプリのエラーが発生したと想定していました。