Thread: Question about the remove function

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    201
    Quote Originally Posted by caduardo21
    The directory I tried to delete was empty but remove still did not work.
    this should give more info why it failed:

    Code:
    int main( int argc, char *argv[] )
    {
        if (remove("somedir") == -1)
        {
            perror("remove failed");
        }
    
        return ( 0 ) ;
    }

  2. #2
    1ST » R. vd Kooij
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    154
    I'm also trying to make my program delete a certain directory atm, I've tried rmdir and remove, but the problem is that my directory will never be empty upon deleting.
    I can think of making a function to enter the directory, search for all files (and sub-dirs) and delete them one by one, but is there NO way this can be done easier? I.e. isnt there a function that deletes dirs regardless whether its empty or not?


    BTW, perror; that's a great tip Laserve, thanks!
    http://www.f1rstracing.nl/
    OS: Windows XP
    Compiler: Dev-C++

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  3. dllimport function not allowed
    By steve1_rm in forum C++ Programming
    Replies: 5
    Last Post: 03-11-2008, 03:33 AM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. Calling a Thread with a Function Pointer.
    By ScrollMaster in forum Windows Programming
    Replies: 6
    Last Post: 06-10-2006, 08:56 AM