See Also: DirectoryNotFoundException Members
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 System.Security.Permissions.FileIOPermissionAttribute.PathDiscovery permission, the error message for this exception may only contain file or directory names instead of fully qualified paths.
The following example demonstrates an error that causes the System.IO.DirectoryNotFoundException exception to be thrown. In this case, the /Mistake/examples/ directory does not exist and therefore cannot be located.
C# Example
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".