Results 1 to 6 of 6

Thread: Deleting a file

  1. #1
    Join Date
    Mar 2010
    Posts
    69
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Deleting a file

    Hi Everyone,
    Can anyone tell me how to delete a file in Qt. I have tried QFile::remove and QDir::remove. But none of them are working as my expectation. Any help will be appreciated.
    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Deleting a file

    For me they work perfect. What do you expect and are you sure you set the right file, which you want delete?

  3. #3
    Join Date
    Mar 2010
    Posts
    69
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Deleting a file

    I have created one database and place it into c:\oxscan\dbFile.db. Now I want to either delete it or clear the contents of it. So I have used the following code;
    QFile File("C:\\Oxscan\\dbFile.DB");
    bool bRemoved = File.remove();

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Deleting a file

    ... and the after that bRemoved is true or false?

    If false, the file is probably in use, so windows does not permit to delete it.

  5. #5
    Join Date
    Mar 2010
    Posts
    69
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Deleting a file

    bRemoved is false. So if I call File.close(), will it work.

  6. #6
    Join Date
    Mar 2010
    Posts
    69
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Deleting a file

    Thanks for your help. Now it is not required to delete the file. I have just deleted the contents and working as my expectation.

Similar Threads

  1. deleting QStringList
    By timmu in forum Qt Programming
    Replies: 5
    Last Post: 18th December 2009, 13:36
  2. Deleting controls
    By alisami in forum Newbie
    Replies: 1
    Last Post: 18th June 2008, 15:19
  3. Deleting a part of a file
    By Sivert in forum General Programming
    Replies: 1
    Last Post: 25th March 2008, 23:43
  4. Deleting QProcess
    By user_mail07 in forum Qt Programming
    Replies: 7
    Last Post: 29th January 2008, 18:55

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.