Can't remove file
-
wrote on 12 Jul 2018, 14:26 last edited by
Hi,
My application extracts a file from it's own resource, but can't remove the created file (because it's read only).
eg:QFile::copy(":/resources/res/line.dwg", "D:/MediaCad/MediaCadQt/win32/debug/temp/line.dwg"); QFile::remove("D:/MediaCad/MediaCadQt/win32/debug/temp/line.dwg");// does not work
How can I fix this ?
Thanks -
Hi,
My application extracts a file from it's own resource, but can't remove the created file (because it's read only).
eg:QFile::copy(":/resources/res/line.dwg", "D:/MediaCad/MediaCadQt/win32/debug/temp/line.dwg"); QFile::remove("D:/MediaCad/MediaCadQt/win32/debug/temp/line.dwg");// does not work
How can I fix this ?
Thanks -
wrote on 12 Jul 2018, 15:09 last edited by
These actions are not adjacents.
Event after application quit, the file is still read only.(Sorry for my english)
-
These actions are not adjacents.
Event after application quit, the file is still read only.(Sorry for my english)
wrote on 12 Jul 2018, 15:41 last edited by JonB 7 Dec 2018, 15:45@Roy44
If it's really true that the file is read-only after copying, under Windows:file.setPermissions(QFile::ReadOther | QFile::WriteOther); file.remove();
Also you should be checking the returns results of your
copy()
andremove()
, and usingQFileDevice::FileError QFileDevice::error() const
to discover the reason why. -
wrote on 13 Jul 2018, 12:34 last edited by
It works with new permissions.
thanks
1/5