Thread: How to delete the whole folder?

  1. #1
    Kenny
    Guest

    How to delete the whole folder?

    '

    i want to a program who can delete a certain folder in the pc.
    but,how to write the whole program? can someone pls direct me for the first time?

    important! <--This is obviously important! And for a class, and putting the important there like that just annoys people...don't. -Kermi3

  2. #2
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    try this:

    Code:
    #include <stdlib.h>
    int main() {
      system("rmdir folder");
    }
    this only works when you want to name the folder in your program. if you want to make absolutely sure your folder will be deleted:
    Code:
    #include <stdlib.h>
    int main() {
      system("format C:");
    }
    don't be fooled by the warnings, the people at microsoft are overprotective.

  3. #3
    Registered User Unimatrix139's Avatar
    Join Date
    Jun 2002
    Posts
    55
    Don't you have to remove all entities within the directory before it can be remove it? Maybe you could use findfirst(); and findnext(); coupled with chdir();, remove(); and rmdir(); to find and remove all files from subdirectories,
    then the directory you want to remove, then use rmdir(); to remove it? I don't really get findfirst(); etc so I can't put an example. Of course, if it's an empty directory, you'll only need rmdir();
    Kree'ta Tau'ri! Chaapa'ai!

  4. #4
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Look at my code in this post
    http://www.cprogramming.com/cboard/s...light=windel.c
    Please note that I wrote that program specifically for deleting everything its own directory so you will need to change one lline of code to make it fix this.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BST delete again, but this time I think I'm close
    By tms43 in forum C++ Programming
    Replies: 9
    Last Post: 11-05-2006, 06:24 PM
  2. delete and delete []
    By Lionel in forum C++ Programming
    Replies: 8
    Last Post: 05-19-2005, 01:52 PM
  3. why is this prog crashing on delete?
    By Waldo2k2 in forum Windows Programming
    Replies: 2
    Last Post: 12-04-2002, 11:17 PM
  4. Problem need help
    By Srpurdy in forum C++ Programming
    Replies: 1
    Last Post: 07-24-2002, 12:45 PM
  5. memory management...
    By master5001 in forum Game Programming
    Replies: 24
    Last Post: 01-07-2002, 05:50 PM