0

I am using the following code to create a new folder in the existing "Games" folder, but it just isnt making the folder.

QDir dir("C:/Games/MyGame");
if(!dir.exists())
{
    dir.mkdir("C:/Games/MyGame");
}
else
{
    qDebug()<<dir.absolutePath() + " exists";
}
SoH
  • 2,180
  • 2
  • 24
  • 53

1 Answers1

0

Make sure you have Games folder in C:/ [check programmatically whether QDir().exists("C:/Games/) is returning true ].

And also make sure that your C:/ Folder doesn't have any file named Games, Because if you have file with same name, the exists function will return false even if the folder is present!. And mkdir will return false!!!

Following piece of code should create the specified directory if its not present.

if (QDir().exists("C:/Games/MyGame"))
{
   qDebug()<<dir.absolutePath() + " exists";
}

else
{
   QDir().mkdir("C:/Games/MyGame");
}
ScarCode
  • 3,074
  • 3
  • 19
  • 32