请问QT中如何实现文件复制呢???

来源:百度知道 编辑:UC知道 时间:2024/05/06 19:19:39
void CEmsFlt::SaveToHis( QString strFileName )
{
QString strPath;
QString strHisPath;

CMainFrame* pMain = (CMainFrame*)AfxGetMainWnd();
if ( nModelRealFlag == 0 )
{
strPath = "c:\\DR6000\\FltBin\\real\\";
strHisPath = strPath + "realhis\\";
}
else
{
strPath = "c:\\DR6000\\FltBin\\model\\";
strHisPath = strPath + "modelhis\\";
}

QTime theTime = QTime::currentTime();
QDate theDate = QDate::currentDate();
QString strTime;
QString strDate;
strTime = QString("'%d'年'%d'月'%d'日'%d'时'%d'分'%d'秒-")
.arg(theDate.year())
.arg(theDate.month())
.arg(theDate.day())
.arg(theTime.hour())
.arg(theTime.minute())
.arg(theTime.second());<

用QFile::copy

附Qt Assistant说明
bool QFile::copy ( const QString & fileName, const QString & newName ) [static]
This is an overloaded member function, provided for convenience.
Copies the file fileName to newName. Returns true if successful; otherwise returns false.
If a file with the name newName already exists, copy() returns false (i.e., QFile will not overwrite it).
See also rename().

要添加头文件引用的吧