I'm getting an unhandled exception of type System.IO.IOException
occurring in mscorlib.dll because the file I'm trying to delete is being used by another process.
I want it to skip the used files.
private void button1_Click(object sender, EventArgs e)
{
System.IO.DirectoryInfo directory =
new System.IO.DirectoryInfo(@"C:\Users\fatih\AppData\Local\Temp");
foreach (System.IO.FileInfo file in directory.GetFiles()) file.Delete();
foreach (System.IO.DirectoryInfo subDirectory in directory.GetDirectories())
subDirectory.Delete(true);
}