Furkan
11th October 2010, 21:02
Hello.
I know how to read files but I discovered something weird the code below works fine.
QFile file(QApplication::applicationDirPath() + "/bilgi.txt");
if(!QFile::exists(QApplication::applicationDirPath () + "/bilgi.txt"))
{
QMessageBox::information(this, "asdasd", "not exists");
}
if(!file.open(QFile::ReadOnly))
{
QMessageBox::information(this, "asdasd", "readonly");
}
QByteArray data = file.readAll();
QTextCodec *codec = QTextCodec::codecForHtml(data);
QString string = codec->toUnicode(data);
QMessageBox::information(this, "asdasd", string);
But when I remove these codes below
if(!QFile::exists(QApplication::applicationDirPath () + "/bilgi.txt"))
{
QMessageBox::information(this, "asdasd", "not exists");
}
if(!file.open(QFile::ReadOnly))
{
QMessageBox::information(this, "asdasd", "readonly");
}
I can't read bilgi.txt file. I really wonder why it is like that.
Is there a really cool reason for that? or I don't know you tell me.
I know how to read files but I discovered something weird the code below works fine.
QFile file(QApplication::applicationDirPath() + "/bilgi.txt");
if(!QFile::exists(QApplication::applicationDirPath () + "/bilgi.txt"))
{
QMessageBox::information(this, "asdasd", "not exists");
}
if(!file.open(QFile::ReadOnly))
{
QMessageBox::information(this, "asdasd", "readonly");
}
QByteArray data = file.readAll();
QTextCodec *codec = QTextCodec::codecForHtml(data);
QString string = codec->toUnicode(data);
QMessageBox::information(this, "asdasd", string);
But when I remove these codes below
if(!QFile::exists(QApplication::applicationDirPath () + "/bilgi.txt"))
{
QMessageBox::information(this, "asdasd", "not exists");
}
if(!file.open(QFile::ReadOnly))
{
QMessageBox::information(this, "asdasd", "readonly");
}
I can't read bilgi.txt file. I really wonder why it is like that.
Is there a really cool reason for that? or I don't know you tell me.