tags:

views:

175

answers:

4

According to the doucmentation for "Directory.Delete( "path", true )", it remove directories, subdirectories, and files in the path.

What does Directory.Delete( "path", false ) do? According to the doucmentation it does "otherwise".

I mean how can you delete a directory without removing the directory, subdirectories, and files?

+3  A: 

Just a quick guess, since I don't do .Net, but I'd say it will only remove empty directories.

Bill James
You were first...
tvanfosson
Ya, I know, but it really was just an educated guess. jleedev actually looked it up, which I can admit was more work than I was willing to put into it.
Bill James
A: 

Second argument tells whether you want a recursive delete. If it's false, the method will throw an IOException if the directory is not empty.

Alexander Kojevnikov
+6  A: 

Bill James is correct. According to MSDN, if the recursive parameter is false and the directory is not empty, IOException will be thrown.

jleedev
You are right, that was burried in the exception explanations.
Fine, DO the research then, TAKE the upticks :) Where's that guy griping about fastest gun in the West, again?
Bill James
A: 

Suppose the intent of the code is to delete directories only if they're empty. Setting the second parameter to false enforces that policy/intent.

Michael Burr