BCL mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 4.0.0.0 All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe. System.IO.IOException System.Runtime.InteropServices.ComVisible(true)

The following example demonstrates an error that causes the exception to be thrown.

`using System; using System.IO; class FileNotFoundExample { public static void Main () { string badPath = "/Eccma/examples/FileTest.cs"; string goodPath = "/Ecma/examples2/FileTest.cs"; try { File.Copy(badPath,goodPath); } catch (FileNotFoundException e) { Console.WriteLine("Caught: {0}",e.Message); } } }`

The output is

Caught: Could not find file "/Eccma/examples/FileTest.cs".

FileNotFoundException uses the HRESULT COR_E_FILENOTFOUND which has the value 0x80070002.

If your code does not have permission, the error message for this exception may only contain file or directory names instead of fully qualified paths.

The exception that is thrown when an attempt to access a file that does not exist on disk fails.

- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  This constructor initializes the 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.

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

  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  This constructor initializes the property of the new instance using .

  Initializes a new instance of the class with its message string set to and its HRESULT set to COR_E_FILENOTFOUND.

  A description of the error. The content of 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.
  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  To be added.

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

  An object that holds the serialized object data about the exception being thrown.
  An object that contains contextual information about the source or destination.
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

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

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

  Property

  Value

  The inner exception reference.

  The error message string.

  For more information on inner exceptions, see .

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

  A description of the error. The content of 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.
  The exception that is the cause of the current exception. If the parameter is not null, the current exception is raised in a catch block that handles the inner exception.
  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  The full name of the file with the invalid image.

  The constructor initializes the property of the new instance using and the property using .

  Initializes a new instance of the class with its message string set to , specifying the file name that cannot be found, and its HRESULT set to COR_E_FILENOTFOUND.

  A description of the error. The content of 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.
  The full name of the file with the invalid image.
  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  The exception that is the cause of the current exception. If the parameter is not null, the current exception is raised in a catch block that handles the inner exception.

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

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

  Property

  Value

  The inner exception reference.

  The error message string.

  For more information on inner exceptions, see .

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

  The error message that explains the reason for the exception.
  The full name of the file with the invalid image.
  The exception that is the cause of the current exception. If the parameter is not null, the current exception is raised in a catch block that handles the inner exception.
  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String

  A containing the name of the file, or if no file name was passed to the constructor for the current instance.

  This property is read-only.

  Gets the name of the file that cannot be found.

  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String To be added. To be added.

  Gets the log file that describes why loading of an assembly failed.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` To be added.

  Sets the object with the file name and additional exception information.

  The object that holds the serialized object data about the exception being thrown. The object that contains contextual information about the source or destination.
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String

  A containing the error message. This string includes the if a value for that property was supplied to the constructor for the current instance.

  If no message was supplied to the constructor for the current exception, this property returns a system-supplied error message. If the property is not null, the message includes the file name.

  This property is read-only.

  Gets the error message that explains the reason for the exception.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String

  The following example causes a exception and displays the result of calling on that Exception.

  `using System; using System.IO; class FileNotFoundExample { public static void Main () { string badPath = "/Eccma/examples/FileTest.cs"; string goodPath = "/Ecma/examples2/FileTest.cs"; try { File.Copy(badPath,goodPath); } catch (FileNotFoundException e) { Console.WriteLine("Caught: {0}",e.ToString()); } } }`

  The output is

  `Caught: System.IO.FileNotFoundException: Could not find file "/Eccma/examples/FileTest.cs". File name: "/Eccma/examples/FileTest.cs" at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite) at FileNotFoundExample.Main()`

  This method overrides .

  The string representation returned by this method includes the name of the exception, the value of the property, the result of calling ToString on the inner exception, the value of the property, and the result of calling . If any of these members is a null reference, its value is not included in the returned string.

  Returns the fully qualified name of this exception and possibly the error message, the name of the inner exception, and the stack trace.

  The fully qualified name of this exception and possibly the error message, the name of the inner exception, and the stack trace.

  0
0