switch (errorCode)
{
case Interop.Errors.ERROR_FILE_NOT_FOUND:
- return string.IsNullOrEmpty(path)
- ? new FileNotFoundException(SR.IO_FileNotFound)
- : new FileNotFoundException(SR.Format(SR.IO_FileNotFound_FileName, path), path);
+ return new FileNotFoundException(
+ string.IsNullOrEmpty(path) ? SR.IO_FileNotFound : SR.Format(SR.IO_FileNotFound_FileName, path), path);
case Interop.Errors.ERROR_PATH_NOT_FOUND:
- return string.IsNullOrEmpty(path)
- ? new DirectoryNotFoundException(SR.IO_PathNotFound_NoPathName)
- : new DirectoryNotFoundException(SR.Format(SR.IO_PathNotFound_Path, path));
+ return new DirectoryNotFoundException(
+ string.IsNullOrEmpty(path) ? SR.IO_PathNotFound_NoPathName : SR.Format(SR.IO_PathNotFound_Path, path));
case Interop.Errors.ERROR_ACCESS_DENIED:
- return string.IsNullOrEmpty(path)
- ? new UnauthorizedAccessException(SR.UnauthorizedAccess_IODenied_NoPathName)
- : new UnauthorizedAccessException(SR.Format(SR.UnauthorizedAccess_IODenied_Path, path));
+ return new UnauthorizedAccessException(
+ string.IsNullOrEmpty(path) ? SR.UnauthorizedAccess_IODenied_NoPathName : SR.Format(SR.UnauthorizedAccess_IODenied_Path, path));
case Interop.Errors.ERROR_ALREADY_EXISTS:
if (string.IsNullOrEmpty(path))
goto default;
return new IOException(SR.Format(SR.IO_AlreadyExists_Name, path), MakeHRFromErrorCode(errorCode));
case Interop.Errors.ERROR_FILENAME_EXCED_RANGE:
- return string.IsNullOrEmpty(path)
- ? new PathTooLongException(SR.IO_PathTooLong)
- : new PathTooLongException(SR.Format(SR.IO_PathTooLong_Path, path));
+ return new PathTooLongException(
+ string.IsNullOrEmpty(path) ? SR.IO_PathTooLong : SR.Format(SR.IO_PathTooLong_Path, path));
case Interop.Errors.ERROR_SHARING_VIOLATION:
- return string.IsNullOrEmpty(path)
- ? new IOException(SR.IO_SharingViolation_NoFileName, MakeHRFromErrorCode(errorCode))
- : new IOException(SR.Format(SR.IO_SharingViolation_File, path), MakeHRFromErrorCode(errorCode));
+ return new IOException(
+ string.IsNullOrEmpty(path) ? SR.IO_SharingViolation_NoFileName : SR.Format(SR.IO_SharingViolation_File, path),
+ MakeHRFromErrorCode(errorCode));
case Interop.Errors.ERROR_FILE_EXISTS:
if (string.IsNullOrEmpty(path))
goto default;
return new OperationCanceledException();
case Interop.Errors.ERROR_INVALID_PARAMETER:
default:
- return string.IsNullOrEmpty(path)
- ? new IOException(GetMessage(errorCode), MakeHRFromErrorCode(errorCode))
- : new IOException($"{GetMessage(errorCode)} : '{path}'");
+ return new IOException(
+ string.IsNullOrEmpty(path) ? GetMessage(errorCode) : $"{GetMessage(errorCode)} : '{path}'",
+ MakeHRFromErrorCode(errorCode));
}
}