DirectoryNotFoundException 类
当找不到文件或目录的一部分时所引发的异常。
**命名空间:**System.IO
**程序集:**mscorlib(在 mscorlib.dll 中)
语法
声明
<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Class DirectoryNotFoundException
Inherits IOException
用法
Dim instance As DirectoryNotFoundException
[SerializableAttribute]
[ComVisibleAttribute(true)]
public class DirectoryNotFoundException : IOException
[SerializableAttribute]
[ComVisibleAttribute(true)]
public ref class DirectoryNotFoundException : public IOException
/** @attribute SerializableAttribute() */
/** @attribute ComVisibleAttribute(true) */
public class DirectoryNotFoundException extends IOException
SerializableAttribute
ComVisibleAttribute(true)
public class DirectoryNotFoundException extends IOException
备注
DirectoryNotFoundException 使用包含值 0x80070003 的 HRESULT COR_E_DIRECTORYNOTFOUND。请注意,当 COM interop 程序看到包含值 0x80030003 的 HRESULT STG_E_PATHNOTFOUND 时,也会引发 DirectoryNotFoundException。
示例
下面的示例显示如何强制引发 DirectoryNotFoundException 以及如何从 DirectoryNotFoundException 恢复。
Imports System.IO
Module Module1
Sub Main()
Try
' Specify a directory name that does not exist for this demo.
Dim dir As String = "c:\78fe9lk"
' If this directory does not exist, a DirectoryNotFoundException is thrown
' when attempting to set the current directory.
Directory.SetCurrentDirectory(dir)
Catch ex As System.IO.DirectoryNotFoundException
' Let the user know that the directory did not exist.
Console.WriteLine("Directory not found: " + ex.Message)
End Try
End Sub
End Module
继承层次结构
System.Object
System.Exception
System.SystemException
System.IO.IOException
System.IO.DirectoryNotFoundException
线程安全
此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。
平台
Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0
.NET Compact Framework
受以下版本支持:2.0、1.0
请参见
参考
DirectoryNotFoundException 成员
System.IO 命名空间
Exception