how do i check if multiple folders exist if so delete them on button click?
Posted
by NightsEVil
on Stack Overflow
See other posts from Stack Overflow
or by NightsEVil
Published on 2010-06-18T06:46:44Z
Indexed on
2010/06/18
6:53 UTC
Read the original article
Hit count: 247
hi i have a few folders created by my application and id like that when they click a button named "clean up" that it would check to see if any of the predetermined folders exist, if they do then delete them, this is what i have tried so far whats wrong with it?
string tempFolder = Environment.GerFolderPath(Environment.SpecialFolder.ApplicationData);
if (Directory.Exists(tempFolder + "//" + "temp1"))
if (Directory.Exists(tempFolder + "//" + "temp2"))
if (Directory.Exists(tempFolder + "//" + "temp3"))
if (Directory.Exists(tempFolder + "//" + "temp4"))
{
System.IO.Directory.Delete(tempFolder + "\\" + "temp1", true);
System.IO.Directory.Delete(tempFolder + "\\" + "temp2", true);
System.IO.Directory.Delete(tempFolder + "\\" + "temp3", true);
System.IO.Directory.Delete(tempFolder + "\\" + "temp4", true);
}
else
{
MessageBox.Show("No Cleanup Needed");
}
so whats wrong? i tested it and it seemed to with 2 folder but not 4 or more
© Stack Overflow or respective owner