关于QFile和QDateTime综合运用的问题
QDir dir;
dir.mkpath("D:/123");
//QFile file("D:/123/message_autosave.txt");
QString file_name = "D:/123/";
file_name += "message_";
file_name += save_begintime.toString("hh:mm:ss (zzz 'ms')");
file_name += "_";
file_name += save_endtime.toString("hh:mm:ss (zzz 'ms')");
file_name += ".txt";
QFile file(file_name); //创建不成功
if (!file.open(QFile::Append | QFile::WriteOnly | QFile::Text))
{
return false;
}
QTextStream out(&file);
if (file.exists())
{
if ((datetime >= m_save_begintime) && (datetime <= m_save_endtime))
{
AutoSaveMessage(pDataObj, save_begintime, save_endtime, strtime, out);
}
else
file.close();
}