Mono Class Library: System.IO Namespace

System.IO.FileNotFoundException Class

Represents the error that occurs when a file path argument specifies a file that does not exist. [Edit]

See Also: FileNotFoundException Members

System.Object
     System.Exception
          System.SystemException
               System.IO.IOException
                    System.IO.FileNotFoundException

[System.Runtime.InteropServices.ComVisible(true)]
public class FileNotFoundException : IOException

Thread Safety

All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.

Remarks

Documentation for this section has not yet been entered. [Edit]

Example

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".

Requirements

Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0