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?

2

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.