views:

1621

answers:

6

Hey all, How delete folder using C++? I am something find at internet, but do not help me :( Can somebody help me?

Thank you

+1  A: 

The C++ Standard defines the remove() function, which may or may not delete a folder, depending on implementation. If it doesn't you need to use an implementation specific function such as rmdir().

anon
+3  A: 

The directory must be empty and your program must have permissions to delete it

but the function called rmdir will do it

rmdir("C:/Documents and Settings/user/Desktop/itsme")
TStamper
+2  A: 

The directory should be empty.

BOOL RemoveDirectory( LPCTSTR lpPathName );
Vinay
This is Windows only I think?I find it funny that Vinay has an Apple avatar, yet posts a Windows-specific answer. ;)
Aardvark
A: 

As far as I can tell, there are no classes/functions in C++ to interact with directories.

You will need to use the C/C++ facilities of your operating system libraries.

Jens
A: 

If you are using windows, then take a look at this link. Otherwise, you may look for your OS specific version api. I don't think C++ comes with a cross-platform way to do it. At the end, it's NOT C++'s work, it's the OS's work.

J.W.
+6  A: 

I strongly advise to use Boost.FileSystem.

http://www.boost.org/doc/libs/1_38_0/libs/filesystem/doc/index.htm

In your case that would be

boost::filesystem::remove_all(yourPath)

Edouard A.