title: Directory is not empty error in c#
body: <p>In my example I am trying to delete the folders under a particular folder. My folder structure like this... <code>C:\Export\MyDir1\MyDir2\MyDir3\MyDir4\MyDir5</code> This structure will come on the fly. Next time when I run my application it should check for <code>C:\Export\MyDir1</code> directory and delete if exists. I written like this</p>
  
  <pre><code>private static string getExportPath(string exportTargetPath, string parentIssue)
          {
              string exportPath = Path.Combine(exportTargetPath, parentIssue);
              if (Directory.Exists(exportPath))
              {
                  string[] files = Directory.GetFiles(exportPath);
                  string[] dirs = Directory.GetDirectories(exportTargetPath);
  
                  File.SetAttributes(exportTargetPath, FileAttributes.Normal);
                  Directory.Delete(exportTargetPath,false);
              }
  
              return exportPath;
          }
  </code></pre>
  
  <p>I checked with the issue posted in this sit <a href="https://stackoverflow.com/questions/329355/cannot-delete-directory-with-directory-deletepath-true">Issue</a>  I tried with this one but can't get solution. As per the suggested answer for this question, when i try to iterate through the directories then it is going to infinite loop. Where I done the mistake? Could any one help me?</p>