文件已经打开,但出现"QIODevice::write: device not open"的错误提示。

4
当我编译程序时,出现错误信息“QIODevice::write:设备未打开”,这个程序在我的旧电脑上可以运行,但是在新电脑上却不能正常工作。请问如何解决此错误?感谢您的帮助。
file.open(QIODevice::Append);
file2.open(QIODevice::Append);

QTextStream stream(&file); //stream of information
QTextStream stream2(&file2);

//write to file
//code continued here, deleted to post here... stream << whatever, stream2 << whatever whatever...

//end stream
stream << endl;
stream2 << endl;

//close file
file.close();
file2.close();

文件没有被打开的可能性吗?我的意思是没有在默认位置写入的权限。 - drescherjm
是的,我认为你是对的,让我检查一下。 - Brandan B
1个回答

7
问题在于我在一个不存在的位置创建了文件,将位置更改为创建文件夹并解决了问题。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接