Delete a directory recursively

Asked

Viewed 33 times

0

Looking at Microsoft documentation on the method System.IO.Directory.Delete(path, bool);i noticed that adding a true boolean in the second parameter makes it recursive.

In my case, the folder I will delete contains files being used by other processes and some read-only files and/or protected by the operating system. Eventually, my app will return a IOException. How can I ignore all files that cannot be deleted? Currently my application hangs in the middle of the process without deleting all possible files...

  • There it is not deleting, but it is the same thing to treat the mistake.

  • Scroll through all the folder files in one <foreach> and for each of them to use a Try/catch block with the correct Ioexception treatment does not resolve?

  • Daniel, solve even solves, but I wanted to use System.IO’s own method

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.