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. In this case, the /Mistake/examples/ directory does not exist and therefore cannot be located.

`using System; using System.IO; class DirectoryNotFoundExample { public static void Main () { string badPath = "/Mistake/examples/"; try { Directory.GetFiles(badPath); } catch (DirectoryNotFoundException e) { Console.WriteLine("Caught: {0}",e.Message); } } }`

The output is

Caught: Could not find a part of the path "C:\Mistake\examples".

DirectoryNotFoundException uses the HRESULT COR_E_DIRECTORYNOTFOUND which has the value 0x80070003. Note that DirectoryNotFoundException is also thrown when COM interop programs see the HRESULT STG_E_PATHNOTFOUND, which has the value 0x80030003.

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 part of a file or directory cannot be found.

- 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 directory." This message takes into account the current system culture.

  The property of the new instance is initialized to null.

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

  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  This constructor initializes the property of the new instance using .

  The property of the new instance is initialized to null.

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

  A that describes 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.

  The that holds the serialized object data about the exception being thrown.
  The 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.

  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 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
0