QT创建相应文件夹在指定目录下

void printResultPackage() //输出成果包
{
	QString relativepath = SMEInterface::instance()->sourcePath();  //得到相对路径Release->运行路径
	QTextCodec::setCodecForLocale(QTextCodec::codecForName("GBK"));    //改成windows系统识别的GBK格式
	QMap countyData = parseFile(relativepath + "/CountyCode.txt");
	QMap::iterator it;// 遍历 
	QDir dir(relativepath);
	if (!dir.cd("./" + QString::fromLocal8Bit("输出成果包")))
	{
		dir.mkdir(QString::fromLocal8Bit("输出成果包"));
	}
	dir.setPath(relativepath);
	if (dir.cd("./" + QString::fromLocal8Bit("输出成果包")))
	{
			for (it = countyData.begin(); it != countyData.end(); it++)
			{
				dir.mkdir(it.value() + it.key() + QString::fromLocal8Bit("初始库"));
				if (dir.cd("./" + it.value() + it.key() + QString::fromLocal8Bit("初始库")))
				{
					dir.mkdir(QString::fromLocal8Bit("文档成果"));
					dir.mkdir(QString::fromLocal8Bit("矢量成果"));
					dir.mkdir(QString::fromLocal8Bit("表格成果"));
					dir.setPath(relativepath + "/" + QString::fromLocal8Bit("输出成果包"));  //设置dir路径,方便重新遍历
				}
			}
			QMessageBox::warning(NULL, QString::fromLocal8Bit("输出成果包"), QString::fromLocal8Bit("输出成果包创建成功"));
	}
}

 

你可能感兴趣的:(C++)