Deleting directories!

L

Lee

Hi,

when deleting a directory using;-

string dir = "whatever";
Directory.Delete(dir);

it fails if files/directories exist within the directory being deleted. is
there an easy way of deleting the directory and all contents without having
to recurse through the entire directory deleting each one ?

thanks in advance
 
G

Galcho[MCSD.NET]

there is overload where you specify recurse

Directory.Delete (String, Boolean) Deletes the specified directory
and, if indicated, any subdirectories in the directory.


example
System.IO.Directory.Delete("c:\MyDir\temp", true);


I hope this helps
Galin Iliev[MCSD.NET]
www.galcho.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top