如何在QT的硬盘中创建文件? [英] How to create a file in the harddisk in QT?

查看:229
本文介绍了如何在QT的硬盘中创建文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在QT的硬盘中创建文件?检查硬盘是否存在???

How to create a file in the hard-disk in QT?? Checking whether the hard disk exists or not???

推荐答案

#include< qfile.h>
#include< qtextstream.h>

QString strfilename ="C:\\ Sample.txt";

QFile pfile(strfilename);

if(pfile.open(IO_WriteOnly | IO_Translate))
{
//文件写入代码将移至此处....
}
其他
{
qDebug(无法创建文件");
}
#include <qfile.h>
#include <qtextstream.h>

QString strfilename = "C:\\Sample.txt";

QFile pfile( strfilename );

if ( pfile.open( IO_WriteOnly | IO_Translate ) )
{
// File Writting code will go here....
}
else
{
qDebug( "Could not create file");
}


这篇关于如何在QT的硬盘中创建文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆