I have a pretty big codebase in .NET 4.7.2 which does a lot of file system manipulation and pretty often calls Directory.Delete(path, true) method, which sometimes yields to IOException or UnauthorizedAccessException.
According to a thread it's because someone else owns a windows handle to a directory.
The code base is using multiple managed threads and I'd like to find out if some other thread/resource holds a handle to a directory.
Is there a way to accomplish that without actually calling Directory.Delete and receiving an exception?