Deleting directories!

  • Thread starter Thread starter Lee
  • Start date Start date
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
 
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
 
Back
Top