新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
Qt刪除文件或非空文件夾-創(chuàng)新互聯(lián)
Qt居然沒有實(shí)現(xiàn)刪除指定目錄的方法,真是無語。自己動(dòng)手,豐衣足食。以下函數(shù)實(shí)現(xiàn)了刪除 指定路徑的文件 或 指定路徑的非空文件夾。
inline bool DeleteFileOrFolder( const QString& strPath )
{
if( strPath.isEmpty() || !QDir().exists( strPath ) )
return false;
QFileInfo fileInfo( strPath );
if( fileInfo.isFile() )
QFile::remove( strPath );
else if( fileInfo.isDir() )
{
QDir qDir( strPath );
qDir.setFilter( QDir::AllEntries | QDir::NoDotAndDotDot );
QFileInfoList fileInfoLst = qDir.entryInfoList();
foreach( QFileInfo qFileInfo, fileInfoLst )
{
if( qFileInfo.isFile() )
qDir.remove( qFileInfo.absoluteFilePath() );
else
{
DeleteFileOrFolder( qFileInfo.absoluteFilePath() );
qDir.rmdir( qFileInfo.absoluteFilePath() );
}
}
qDir.rmdir( fileInfo.absoluteFilePath() );
}
return true;
}
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
當(dāng)前標(biāo)題:Qt刪除文件或非空文件夾-創(chuàng)新互聯(lián)
分享網(wǎng)址:http://www.dlmjj.cn/article/hpgpj.html