Deleting entire folders

This is a discussion on Deleting entire folders within the C++ Programming forums, part of the General Programming Boards category; This is my second stupid, newbie question, but please don't flame me. I couldn't find it in the tutorials or ...

  1. #1
    SirDavidGuy
    Guest

    Deleting entire folders

    This is my second stupid, newbie question, but please don't flame me. I couldn't find it in the tutorials or in the FAQ.

    How do you delete entire folders, all at once?

  2. #2
    Registered User
    Join Date
    Jan 2002
    Posts
    552
    you have to delete all the files within the folder first, then delete the folder.

  3. #3
    Registered User Paro's Avatar
    Join Date
    Feb 2002
    Posts
    160
    i think he wants to send a program to a friend that will delete a folder and all its contents from his friends computer

    btw i dont know how
    Paro

  4. #4
    SirDavidGuy
    Guest
    I need it because i'm writing a program which deletes the windows temporary internet files (The REALLY hidden, not just hidden). I don't know how to delete anything, and even if I did, I wouldn't know what to delete, since the Temp files are different on every computer.

  5. #5
    Registered User Paro's Avatar
    Join Date
    Feb 2002
    Posts
    160
    i dont even know how to delete files, could someone fill me in on that
    Paro

  6. #6
    Registered User C_Coder's Avatar
    Join Date
    Oct 2001
    Posts
    523
    The function remove will erase files, its in <stdio.h>.
    Code:
    int remove(char *filename);
    it returns zero if successful
    All spelling mistakes, syntatical errors and stupid comments are intentional.

  7. #7
    SirDavidGuy
    Guest
    Does it work with folders?

  8. #8
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    use rmdir command in dir.h

    rmdir deletes the directory whose path is given by path. The directory named by path

    must be empty
    must not be the current working directory
    must not be the root directory

    rmdir(path);

  9. #9
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    or... the inevitible and slow system command that doesn't matter if there is files in it...

    Code:
    system ("deltree C:\\directory");
    With the only problem being that it may ask you if "you are sure (y/n)".

    system is found in stdlib

    BZ out...

    ***edit****

    The /Y switch will allow you do it without the prompts sooooo...

    system ("deltree /Y C:\\directory");
    Last edited by Betazep; 03-02-2002 at 10:21 PM.
    Blue

  10. #10
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    >>i think he wants to send a program to a friend that will delete a folder and all its contents from his friends computer

    btw i dont know how<<

    and you know what the sad thing is.... it doesn't come up as a virus.
    Blue

  11. #11
    Registered User
    Join Date
    Nov 2001
    Posts
    17
    This works well to

    rmdir /s/q dirName

    whole dir, all files, any subfolders No Y/N questions
    -----------------------------------------------
    everready

    To code, or not to code, that is the question.

    Well the answer is 'TO CODE' of cause

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Error while trying to list folders
    By Hellbinder in forum Networking/Device Communication
    Replies: 5
    Last Post: 06-12-2009, 06:27 PM
  2. Deleting folders and sub folders
    By Boomba in forum C++ Programming
    Replies: 30
    Last Post: 06-11-2003, 12:58 PM
  3. Deleting Folders
    By Kyoto Oshiro in forum C++ Programming
    Replies: 5
    Last Post: 03-31-2002, 05:19 PM
  4. Deleting folders with everything in the directoy
    By knight543 in forum C++ Programming
    Replies: 1
    Last Post: 02-26-2002, 08:45 PM
  5. Replies: 12
    Last Post: 01-23-2002, 07:56 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21