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.
  • Roy44R Offline
    Roy44R Offline
    Roy44
    wrote on 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
    0
    • Roy44R Roy44

      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 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
      • Roy44R Offline
        Roy44R Offline
        Roy44
        wrote on last edited by
        #3

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

        (Sorry for my english)

        JonBJ 1 Reply Last reply
        0
        • Roy44R Roy44

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

          (Sorry for my english)

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #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
          • Roy44R Offline
            Roy44R Offline
            Roy44
            wrote on last edited by
            #5

            It works with new permissions.
            thanks

            1 Reply Last reply
            0

            • Login

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