/* 写文件 */ QFile file(filePath); bool bo = file.open(QIODevice::WriteOnly | QIODevice::Append); //qDebug() << bo; QTextStream text_stream(&file); text_stream << byte; file.flush(); file.close(); /* 遍历文件且删除或创建 */ QDir dir(strFeatures); if(dir.exists()) { qDebug() << strFeatures << " has exist"; QStringList files; QStringList nameFilters; nameFilters << "*.json"; files = dir.entryList(nameFilters,QDir::Files|QDir::Readable,QDir::Name); for(auto file : files) { dir.remove(file); } }else { qWarning() << strFeatures << " not exist"; dir.mkdir(strFeatures); }