delete all files and folders in multiple directory but leave the directoy

Posted by NightsEVil on Stack Overflow See other posts from Stack Overflow or by NightsEVil
Published on 2010-06-02T02:56:47Z Indexed on 2010/06/02 4:43 UTC
Read the original article Hit count: 294

Filed under:
|

well i like this nice of code right here it seems to work awsome but i cant seem to add any more directories to it

DirectoryInfo dir = new DirectoryInfo(@"C:\temp"); 

foreach(FileInfo files in dir.GetFiles())
{
    files.Delete();
}

foreach (DirectoryInfo dirs in dir.GetDirectories())
{
    dirs.Delete(true);
}

i would also like to add in special folders aswell like History and cookies and such how would i go about doing that (i would like to include atleast 4-5 different folders)

© Stack Overflow or respective owner

Related posts about c#

Related posts about delete