See Also: FileNotFoundException Members
FileNotFoundException uses the HRESULT COR_E_FILENOTFOUND which has the value 0x80070002.
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.FileNotFoundException exception to be thrown.
C# Example
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".