deleting folder and subfolders in c#
<p>I have a folder that contains sub folders and files with read only attribute (both files and folders). I want to delete this folder with sub-folders and files.</p>

<p>I wrote this code: </p>

<pre><code>static void Main(string[] args)
{        
    DirectoryInfo mm = new DirectoryInfo(@"c:\ex");
    string aa = Convert.ToString(mm);
    string[] allFileNames = 
        System.IO.Directory.GetFiles(aa, 
                                     "*.*", 
                                     System.IO.SearchOption.AllDirectories);
    string[] alldirNames = 
       System.IO.Directory.GetDirectories(aa, 
                                        "*", 
                                        System.IO.SearchOption.AllDirectories);

    foreach (string filename in allFileNames)
    {
        FileAttributes attr = File.GetAttributes(filename);
        File.SetAttributes(filename, attr &amp; ~FileAttributes.ReadOnly);

    }

    foreach (string dirname in alldirNames)
    {
        FileAttributes attr = File.GetAttributes(dirname);
        File.SetAttributes(dirname, attr &amp; ~FileAttributes.ReadOnly);
        Directory.Delete(dirname  , true);
    }

    FileInfo[] list = mm.GetFiles();

    foreach (FileInfo k in list)
    {
        k.Delete();
    }
    mm.Delete();
    Console.ReadKey();
}
</code></pre>

<p>The problem now is that whenever I run the program it gives me the following error: </p>

<blockquote>
  <p>Could not find a part of the path 'c:\ex\xx\bb'.</p>
</blockquote>

<p>What does this error mean?</p>
