Can't delete temp files because of errors
<p>I'm getting an unhandled exception of type <code>System.IO.IOException</code> occurring in mscorlib.dll because the file I'm trying to delete is being used by another process.</p>

<p>I want it to skip the used files.</p>

<pre><code>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);
}
</code></pre>