我正在尝试写入一个文件,如果该文件不存在,请创建它。我在互联网上搜索过,但没有任何结果。
我的代码当前如下所示:
QString filename="Data.txt";
QFile file( filename );
if ( file.open(QIODevice::ReadWrite) )
{
QTextStream stream( &file );
stream << "something" << endl;
}
If I create a text file called Data in the directory, it remains empty. If I don t create anything it doesn t create the file either. I don t know what to do with this, this isn t the first way in which I tried to create/write into a file and none of the ways worked.
谢谢你的回答。