FileNotFoundExceptionExtensions Class
Provides ThrowNew extension methods for FileNotFoundException.
public static class FileNotFoundExceptionExtensionsRemarks
Each public constructor of the exception type has two methods, with the parameters of the constructor. Call them on the exception type, as in FileNotFoundException.ThrowNew(message).
The first method returns no value. Call it as a statement.
The second method has a type parameter, which is also its return type. Call it where the code needs an expression of that type.
See also
Methods
FileNotFoundException.ThrowNew overloads
FileNotFoundException.ThrowNew()
Throws a new FileNotFoundException.
extension(FileNotFoundException)
{
public static void ThrowNew()
}FileNotFoundException.ThrowNew(string?)
Throws a new FileNotFoundException.
extension(FileNotFoundException)
{
public static void ThrowNew(string? message)
}Parameters
messagestring?- A description of the error. The content of
messageis intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture.
FileNotFoundException.ThrowNew(string?, Exception?)
Throws a new FileNotFoundException.
extension(FileNotFoundException)
{
public static void ThrowNew(string? message, Exception? innerException)
}Parameters
messagestring?- A description of the error. The content of
messageis intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture. innerExceptionException?- The exception that is the cause of the current exception. If the
innerExceptionparameter is notnull, the current exception is raised in acatchblock that handles the inner exception.
FileNotFoundException.ThrowNew(string?, string?)
Throws a new FileNotFoundException.
extension(FileNotFoundException)
{
public static void ThrowNew(string? message, string? fileName)
}Parameters
messagestring?- A description of the error, or
nullto use a system-supplied message with the givenfileName. The content ofmessageshould be understood by humans. The caller of this constructor must ensure that this string has been localized for the current system culture. fileNamestring?- The full name of the file with the invalid image.
FileNotFoundException.ThrowNew(string?, string?, Exception?)
Throws a new FileNotFoundException.
extension(FileNotFoundException)
{
public static void ThrowNew(string? message, string? fileName, Exception? innerException)
}Parameters
messagestring?- The error message that explains the reason for the exception.
fileNamestring?- The full name of the file with the invalid image.
innerExceptionException?- The exception that is the cause of the current exception. If the
innerExceptionparameter is notnull, the current exception is raised in acatchblock that handles the inner exception.
FileNotFoundException.ThrowNew<T>()
Throws a new FileNotFoundException, where the code needs an expression of type T.
extension(FileNotFoundException)
{
public static T ThrowNew<T>()
}Type parameters
T- The type of the expression.
Returns
T This method does not return.
FileNotFoundException.ThrowNew<T>(string?)
Throws a new FileNotFoundException, where the code needs an expression of type T.
extension(FileNotFoundException)
{
public static T ThrowNew<T>(string? message)
}Type parameters
T- The type of the expression.
Parameters
messagestring?- A description of the error. The content of
messageis intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture.
Returns
T This method does not return.
FileNotFoundException.ThrowNew<T>(string?, Exception?)
Throws a new FileNotFoundException, where the code needs an expression of type T.
extension(FileNotFoundException)
{
public static T ThrowNew<T>(string? message, Exception? innerException)
}Type parameters
T- The type of the expression.
Parameters
messagestring?- A description of the error. The content of
messageis intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture. innerExceptionException?- The exception that is the cause of the current exception. If the
innerExceptionparameter is notnull, the current exception is raised in acatchblock that handles the inner exception.
Returns
T This method does not return.
FileNotFoundException.ThrowNew<T>(string?, string?)
Throws a new FileNotFoundException, where the code needs an expression of type T.
extension(FileNotFoundException)
{
public static T ThrowNew<T>(string? message, string? fileName)
}Type parameters
T- The type of the expression.
Parameters
messagestring?- A description of the error, or
nullto use a system-supplied message with the givenfileName. The content ofmessageshould be understood by humans. The caller of this constructor must ensure that this string has been localized for the current system culture. fileNamestring?- The full name of the file with the invalid image.
Returns
T This method does not return.
FileNotFoundException.ThrowNew<T>(string?, string?, Exception?)
Throws a new FileNotFoundException, where the code needs an expression of type T.
extension(FileNotFoundException)
{
public static T ThrowNew<T>(string? message, string? fileName, Exception? innerException)
}Type parameters
T- The type of the expression.
Parameters
messagestring?- The error message that explains the reason for the exception.
fileNamestring?- The full name of the file with the invalid image.
innerExceptionException?- The exception that is the cause of the current exception. If the
innerExceptionparameter is notnull, the current exception is raised in acatchblock that handles the inner exception.
Returns
T This method does not return.