Qt cannot cannot create/write to C:\\

落爺英雄遲暮 提交于 2019-12-01 06:07:15

Have you checked whether the file isn't created in the VirtualStore for that user? Check the Event Viewer under Applications and Services Logs -> Microsoft -> Windows -> UacFileVirtualization -> Operational. If you see entries with event ID 5000, a FileCreateVirtualExclude event has occurred.

Check if the file didn't get created under %USERPROFILE%\AppData\Local\VirtualStore. If it did, you might need to embed a manifest requesting the required privileges (i.e., turning virtualization off.)

For more details, see New UAC Technologies for Windows Vista (scroll down and look for Virtualization.)

You need to acquire sufficient user access rights (ie "Run as Administrator") to write to such folders in Windows Vista+. Either start the app as administrator, or ask for Administrator rights via a call to WinAPI.

QFile may be giving you an error code, but you've failed to check for it.

You should do something more like:

if (!debugFile.open(QFile::WriteOnly)) {
    qWarning() << "Failed to open" << debugFile.fileName() << "for write:" << debugFile.errorString();
}

You've checked the return value of QFile::error, but only before calling open - you need to check after the open attempt.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!