/// <summary>
 /// Throws an exception if the native error code was corresponds to a known <see cref="EnumerateDirectoryStatus"/>
 /// (and enumeration was not successful).
 /// </summary>
 public static Exception ThrowForKnownError(this EnumerateDirectoryResult result)
 {
     Contract.Requires(result.Status != EnumerateDirectoryStatus.UnknownError && result.Status != EnumerateDirectoryStatus.Success);
     throw result.CreateExceptionForError();
 }