private void Directory_Delete_ThrowUnauthorizedAccessException_DirectoryHasDenyPermission(bool isNetwork) { using (var tempRoot = new TemporaryDirectory(isNetwork)) { var folder = System.IO.Directory.CreateDirectory(System.IO.Path.Combine(tempRoot.Directory.FullName, "Existing Source Folder")); Console.WriteLine("Input Directory Path: [{0}]", folder); // Set DENY permission for current user. tempRoot.SetDirectoryDenyPermission(true, folder.FullName); try { ExceptionAssert.IOException(() => System.IO.Directory.Delete(folder.FullName)); // 2018-05-29 BUG: Throws wrong Exception. ExceptionAssert.UnauthorizedAccessException(() => Alphaleonis.Win32.Filesystem.Directory.Delete(folder.FullName)); } finally { // Remove DENY permission for current user. tempRoot.SetDirectoryDenyPermission(false, folder.FullName); } } Console.WriteLine(); }