Editare

Partajați prin


FileNotFoundException Constructors

Definition

Initializes a new instance of the FileNotFoundException class with optional message string and inner Exception reference.

Overloads

FileNotFoundException()

Initializes a new instance of the FileNotFoundException class with its message string set to a system-supplied message.

FileNotFoundException(String)

Initializes a new instance of the FileNotFoundException class with a specified error message.

FileNotFoundException(SerializationInfo, StreamingContext)
Obsolete.

Initializes a new instance of the FileNotFoundException class with the specified serialization and context information.

FileNotFoundException(String, Exception)

Initializes a new instance of the FileNotFoundException class with a specified error message and a reference to the inner exception that is the cause of this exception.

FileNotFoundException(String, String)

Initializes a new instance of the FileNotFoundException class with a specified error message, and the file name that cannot be found.

FileNotFoundException(String, String, Exception)

Initializes a new instance of the FileNotFoundException class with a specified error message, the file name that cannot be found, and a reference to the inner exception that is the cause of this exception.

FileNotFoundException()

Source:
FileNotFoundException.cs
Source:
FileNotFoundException.cs
Source:
FileNotFoundException.cs

Initializes a new instance of the FileNotFoundException class with its message string set to a system-supplied message.

public:
 FileNotFoundException();
public FileNotFoundException ();
Public Sub New ()

Remarks

This constructor initializes the Message property of the new instance to a system-supplied message that describes the error, such as "Could not find the specified file." This message takes into account the current system culture.

See also

Applies to

FileNotFoundException(String)

Source:
FileNotFoundException.cs
Source:
FileNotFoundException.cs
Source:
FileNotFoundException.cs

Initializes a new instance of the FileNotFoundException class with a specified error message.

public:
 FileNotFoundException(System::String ^ message);
public FileNotFoundException (string message);
public FileNotFoundException (string? message);
new System.IO.FileNotFoundException : string -> System.IO.FileNotFoundException
Public Sub New (message As String)

Parameters

message
String

A description of the error. The content of message is 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.

Remarks

This constructor initializes the Message property of the new instance using message.

See also

Applies to

FileNotFoundException(SerializationInfo, StreamingContext)

Source:
FileNotFoundException.cs
Source:
FileNotFoundException.cs
Source:
FileNotFoundException.cs

Caution

This API supports obsolete formatter-based serialization. It should not be called or extended by application code.

Initializes a new instance of the FileNotFoundException class with the specified serialization and context information.

protected:
 FileNotFoundException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected FileNotFoundException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected FileNotFoundException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.IO.FileNotFoundException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.IO.FileNotFoundException
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.IO.FileNotFoundException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.IO.FileNotFoundException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

Parameters

info
SerializationInfo

An object that holds the serialized object data about the exception being thrown.

context
StreamingContext

An object that contains contextual information about the source or destination.

Attributes

See also

Applies to

FileNotFoundException(String, Exception)

Source:
FileNotFoundException.cs
Source:
FileNotFoundException.cs
Source:
FileNotFoundException.cs

Initializes a new instance of the FileNotFoundException class with a specified error message and a reference to the inner exception that is the cause of this exception.

public:
 FileNotFoundException(System::String ^ message, Exception ^ innerException);
public FileNotFoundException (string message, Exception innerException);
public FileNotFoundException (string? message, Exception? innerException);
new System.IO.FileNotFoundException : string * Exception -> System.IO.FileNotFoundException
Public Sub New (message As String, innerException As Exception)

Parameters

message
String

A description of the error. The content of message is 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.

innerException
Exception

The exception that is the cause of the current exception. If the innerException parameter is not null, the current exception is raised in a catch block that handles the inner exception.

Remarks

An exception that is thrown as a direct result of a previous exception should include a reference to the previous exception in the InnerException property. The InnerException property returns the same value that is passed into the constructor, or null if the InnerException property does not supply the inner exception value to the constructor.

The following table shows the initial property values for an instance of FileNotFoundException.

Property Value
InnerException The inner exception reference.
Message The error message string.

For more information on inner exceptions, see InnerException.

See also

Applies to

FileNotFoundException(String, String)

Source:
FileNotFoundException.cs
Source:
FileNotFoundException.cs
Source:
FileNotFoundException.cs

Initializes a new instance of the FileNotFoundException class with a specified error message, and the file name that cannot be found.

public:
 FileNotFoundException(System::String ^ message, System::String ^ fileName);
public FileNotFoundException (string message, string fileName);
public FileNotFoundException (string? message, string? fileName);
new System.IO.FileNotFoundException : string * string -> System.IO.FileNotFoundException
Public Sub New (message As String, fileName As String)

Parameters

message
String

A description of the error, or null to use a system-supplied message with the given fileName. The content of message should be understood by humans. The caller of this constructor must ensure that this string has been localized for the current system culture.

fileName
String

The full name of the file with the invalid image.

Remarks

The constructor initializes the Message property of the new instance using message and the FileName property using fileName.

See also

Applies to

FileNotFoundException(String, String, Exception)

Source:
FileNotFoundException.cs
Source:
FileNotFoundException.cs
Source:
FileNotFoundException.cs

Initializes a new instance of the FileNotFoundException class with a specified error message, the file name that cannot be found, and a reference to the inner exception that is the cause of this exception.

public:
 FileNotFoundException(System::String ^ message, System::String ^ fileName, Exception ^ innerException);
public FileNotFoundException (string message, string fileName, Exception innerException);
public FileNotFoundException (string? message, string? fileName, Exception? innerException);
new System.IO.FileNotFoundException : string * string * Exception -> System.IO.FileNotFoundException
Public Sub New (message As String, fileName As String, innerException As Exception)

Parameters

message
String

The error message that explains the reason for the exception.

fileName
String

The full name of the file with the invalid image.

innerException
Exception

The exception that is the cause of the current exception. If the innerException parameter is not null, the current exception is raised in a catch block that handles the inner exception.

Remarks

An exception that is thrown as a direct result of a previous exception should include a reference to the previous exception in the InnerException property. The InnerException property returns the same value that is passed into the constructor, or null if the InnerException property does not supply the inner exception value to the constructor.

The following table shows the initial property values for an instance of FileNotFoundException.

Property Value
InnerException The inner exception reference.
Message The error message string.

For more information on inner exceptions, see InnerException.

See also

Applies to