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
版权声明:本文为weixin_35756624原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。