budda
16th November 2011, 20:57
having problem using
QString dataPath = QDesktopServices::storageLocation(QDesktopServices ::DataLocation);
QString dataRoot = dataPath;
dataPath += "\\TestProgram\\";
QDir dataDir(dataPath);
if(!dataDir.exists())
{
QDir dataRootD(dataRoot);
dataRootD.mkdir("TestProgram");
}
this works just fine, but apparently it doesn't like writing a text file in here, if it doesn't exist already? isn't that the whole purpose of a datalocation?
Added after 52 minutes:
duh.... this works just fine, and writes just fine....
didn't realize I was trying to Open/Read a non-existing file first... before a check to create the file if it doesn't exist....
QString dataPath = QDesktopServices::storageLocation(QDesktopServices ::DataLocation);
QString dataRoot = dataPath;
dataPath += "\\TestProgram\\";
QDir dataDir(dataPath);
if(!dataDir.exists())
{
QDir dataRootD(dataRoot);
dataRootD.mkdir("TestProgram");
}
this works just fine, but apparently it doesn't like writing a text file in here, if it doesn't exist already? isn't that the whole purpose of a datalocation?
Added after 52 minutes:
duh.... this works just fine, and writes just fine....
didn't realize I was trying to Open/Read a non-existing file first... before a check to create the file if it doesn't exist....