PDA

View Full Version : Problem in reading xml in win7



athulms
13th October 2011, 12:49
In my project i try to open an xml from my current directory. I works perfectly in win xp and some versions of win7.
But in win7 ultimate it does not open the xml. why is it. The same build works in win xp. Is there any plugin needed to be installed in win7 ?? how can i rectify this issue

wysota
13th October 2011, 14:15
This is unrelated to Qt. Most likely you don't have permissions to the file or the file doesn't exist. It could simply be that the current working directory is different. Do you check that the file exists before trying to access it?

athulms
14th October 2011, 08:25
on the first run we create the file in the current directory. I in some version of win7 the xml is not created.
void mainwindow::checkscoreboardfile()
{

dir=new QDir(dir->currentPath());
QFile file(dir->filePath("Score.xml"));
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
if (file.open(QIODevice::WriteOnly))
{
QXmlStreamWriter* xmlWriter = new QXmlStreamWriter();
xmlWriter->setDevice(&file);
xmlWriter->writeStartElement("Score");
xmlWriter->writeEndElement();
file.close();
}
}
}

wysota
14th October 2011, 11:00
Test what the current directory is. You probably don't have permissions to create files there.