Results 1 to 3 of 3

Thread: QFile or QDir rename()

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    132
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QFile or QDir rename()

    Qt tries to be smart and emulate unix-like rename across directories on windows, e.g. when operating system rename fails it tries a copy/delete, but does not check completely for success on deleting the old file.

    As a workaround I suggest to make your own function. Something along this should work (did not test myself though):

    Qt Code:
    1. #include "qt_windows.h"
    2.  
    3. bool winRenameFile(const QString& aOldName, const QString& aNewName)
    4. {
    5. return MoveFile((LPWSTR)aOldName.utf16(), (LPWSTR)aNewName.utf16());
    6. } // winRenameFile
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to seneca for this useful post:

    maxpower (23rd January 2009)

  3. #2
    Join Date
    Oct 2006
    Posts
    60
    Thanks
    9
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: QFile or QDir rename()

    Thanks, that worked as I expected.

    mAx

Similar Threads

  1. QDir and QFile
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 27th September 2007, 13:43
  2. How to explicitely delete a QDir?
    By alan in forum Newbie
    Replies: 2
    Last Post: 13th February 2006, 17:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.