System.IO.FileNotFoundException异常是在试图打开不存在的文件时抛出的异常。要捕获这种异常,可以使用try-catch语句,在可能引发异常的代码块中放置try语句,并在其中放置catch语句以处理异常。
示例:
try { FileStream file = new FileStream("data.txt", FileMode.Open); // Do something with the file file.Close(); } catch (FileNotFoundException ex) { Console.WriteL