I am using Qt 4.7 installed on Ubuntu 10.04 .... I can't create a qt file inside a location other than the current directory "."
This code works well:
QFile file("data.txt");
if (!file.open(QIODevice::Append))
{
qDebug("ERROR WHILE OPENING THE FILE TO APPEND Data");
return ;
}
but this code fails (I think because of the permissions):
QFile file("/var/lib/mysql/testdb/data.txt");
if (!file.open(QIODevice::Append))
{
qDebug("ERROR WHILE OPENING THE FILE TO APPEND Data");
return ;
}
So, how can I solve this problem and give the program permissions to create the file wherever at the file system??
You solve this quickly in one of these ways:
chmod /the/dir o+rwx
- this lets everyone write to the directory.chown myuser /the/dir
- this lets your user write to the directory.You solve this correctly by sticking to directories that your current user can access - permissions are there for a reason.