如何获取文件异常

时间:2014-11-18 02:33:35

标签: vb.net

我创建了一个.ini文件。我正在编写.ini中的ini_class文件的编程。我想知道VB.NET中的一件事。

当找不到文件时,我在读取模式下需要一个例外。我在MSDN上搜索过,我找不到任何东西。

这在VB.NET中是否可行?

1 个答案:

答案 0 :(得分:1)

您可以使用Throw创建例外。

  

当找不到文件时,我需要关于读取模式的例外。

您应该使用FileNotFoundException

Throw New FileNotFoundException

另请查看each constructor。 您可以在此处设置自定义消息:

Throw New FileNotFoundException("Could not open the stream: file not found.")