Results 1 to 3 of 3

Thread: how to delete a file

  1. #1
    Join Date
    Jul 2011
    Posts
    81
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default how to delete a file

    how can i delete a file i used the code
    Qt Code:
    1. dir=new QDir(dir->currentPath());
    2. QFile file3(dir->filePath("Time.xml"));
    3. file3.remove();
    To copy to clipboard, switch view to plain text mode 
    but it doesnot works and returns false.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to delete a file

    Qt Code:
    1. QFile::remove("Time.xml"); // assuming Time.xml is in current dir
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: how to delete a file

    ... and check the return value of QFile::remove() and QFile::error() if you want to know when and why it failed (for example, the file does not exist, is locked, or you have insufficient permission).

Similar Threads

  1. delete first row of data from .csv file?
    By babymonsta in forum Qt Programming
    Replies: 3
    Last Post: 20th May 2010, 03:39
  2. Delete character from file
    By kaszewczyk in forum Newbie
    Replies: 2
    Last Post: 11th March 2010, 18:07
  3. delete a single file from a directory
    By rishiraj in forum Newbie
    Replies: 1
    Last Post: 12th March 2009, 05:46
  4. how to delete a file?
    By whoops.slo in forum Qt Programming
    Replies: 4
    Last Post: 22nd November 2006, 14:27
  5. How to delete File
    By rajesh in forum Qt Programming
    Replies: 1
    Last Post: 7th November 2006, 11:23

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.