Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Open file in uwp app
Forum Updated to NodeBB v4.3 + New Features

Open file in uwp app

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 660 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rivka Cohen
    wrote on last edited by
    #1

    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

    jsulmJ 1 Reply Last reply
    0
    • R Rivka Cohen

      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

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @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?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • R Offline
        R Offline
        Rivka Cohen
        wrote on last edited by
        #3

        @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

        jsulmJ 1 Reply Last reply
        0
        • R Rivka Cohen

          @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

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by jsulm
          #4

          @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

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          R 1 Reply Last reply
          2
          • jsulmJ jsulm

            @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

            R Offline
            R Offline
            Rivka Cohen
            wrote on last edited by
            #5

            @jsulm

            Thank you!
            I used the qstandartpaths class and it succeed!

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved