[SOLVED] QFile open error
-
Hi All,
I am trying to read a simple text file through QFile and its returning "Unknown Error".
@QFile file("E:/123.txt");
if(file.exists()){
qDebug()<<"File Exists";QFile f(QString("E:/123.txt"));
if(f.isOpen()){
f.close();
}else{
if(!f.open(QIODevice::ReadOnly | QIODevice::Text))
qDebug()<<f.errorString();
else
qDebug()<<"It worked.";
}
}@On executing I get the following debug lines:
@File Exists
Unknown Error@What am I missing here?
-
Not really, that was mistake :(
Updated my code to:
@QFile file("E:/123.txt");
if(file.exists()){
qDebug()<<"File Exists";if(file.isOpen()){
file.close();
}else{
if(file.open(QIODevice::ReadOnly | QIODevice::Text))
qDebug()<<file.errorString();
else
qDebug()<<"It worked";
}
}@still having the same error.