Open file in uwp app
-
Hello, I develop application in qt 5.12.3 for UWP 64 bit in order to run it on windows IoT.
I try to open a file but it failed:QString errMsg; QFile file("files/testFile.txt"); if(file.open(QIODevice::WriteOnly)){ qDebug("Open file"); } else{ errMsg = file.errorString(); qDebug("cannot open file err[%s] \n",errMsg.toLatin1().data()); }
output:
qt.winrtrunner.app: cannot open file err[Access is denied.]Can anyone help?
Thanks
Rivka -
@Rivka-Cohen said in Open file in uwp app:
files/testFile.txt
You're using a relative path - are you sure it is in current working directory when you call open?
"Access is denied" - you're trying to open in write mode - are you sure the file is in a writeable location and is writeable? -
@jsulm said in Open file in uwp app:
You're using a relative path - are you sure it is in current working directory when you call open?
"Access is denied" - you're trying to open in write mode - are you sure the file is in a writeable location and is writeable?If I using qt mingw there is no problem to create or open any file but with UWP it impossible to create file at any location .
also I try to open UART that is simple with mingw but I didn't success
I didn't success to use any file IO system call when I use the UWP framework.
do you have any example for UWP QT application that access file system or Serial Port ?Thanks
-
@Rivka-Cohen See https://docs.microsoft.com/en-us/windows/uwp/files/file-access-permissions
UWP is restrictive (just like Android/iOS) when it comes to file access.
Use https://doc.qt.io/qt-5/qstandardpaths.html to find a writeable location.As far as I know Qt does not support serial port communication on UWP. See https://bugreports.qt.io/browse/QTBUG-67628