0

I do this in my code:

Directory.Delete(MapPath("..\\Directory1"),true);

Now I got this error:
System.IO.IOException: The directory is not empty.

What do I wrong anyone a idea?

Will_G
  • 269
  • 2
  • 5
  • 18

1 Answers1

1

try to delete all files and folders inside the directory you want to delete and then delete the directory.

System.IO.DirectoryInfo projectDetailsInfo = new DirectoryInfo(pathofyourdirectory);

foreach (FileInfo file in projectDetailsInfo.GetFiles())
{
       file.Delete();
}
foreach (DirectoryInfo dir in projectDetailsInfo.GetDirectories())
{
  dir.Delete(true);
}
Directory.Delete(path);

hope this will help you.

gofor.net
  • 4,218
  • 10
  • 43
  • 65