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. Can't remove file
QtWS25 Last Chance

Can't remove file

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.9k 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
    Roy44
    wrote on 12 Jul 2018, 14:26 last edited by
    #1

    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

    K 1 Reply Last reply 12 Jul 2018, 14:47
    0
    • R Roy44
      12 Jul 2018, 14:26

      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

      K Offline
      K Offline
      koahnig
      wrote on 12 Jul 2018, 14:47 last edited by
      #2

      @Roy44

      Wild guess that you have overlapping actions. The OS did not finish the writing process before you try to delete.

      Are those actions adjacent?
      When yes, give the OS some time to finish actions.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      2
      • R Offline
        R Offline
        Roy44
        wrote on 12 Jul 2018, 15:09 last edited by
        #3

        These actions are not adjacents.
        Event after application quit, the file is still read only.

        (Sorry for my english)

        J 1 Reply Last reply 12 Jul 2018, 15:41
        0
        • R Roy44
          12 Jul 2018, 15:09

          These actions are not adjacents.
          Event after application quit, the file is still read only.

          (Sorry for my english)

          J Offline
          J Offline
          JonB
          wrote on 12 Jul 2018, 15:41 last edited by JonB 7 Dec 2018, 15:45
          #4

          @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() and remove(), and using QFileDevice::FileError QFileDevice::error() const to discover the reason why.

          1 Reply Last reply
          3
          • R Offline
            R Offline
            Roy44
            wrote on 13 Jul 2018, 12:34 last edited by
            #5

            It works with new permissions.
            thanks

            1 Reply Last reply
            0

            4/5

            12 Jul 2018, 15:41

            • Login

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