IOException クラス

I/O エラーが発生したときにスローされる例外。

この型のすべてのメンバの一覧については、IOException メンバ を参照してください。

System.Object
   System.Exception
      System.SystemException
         System.IO.IOException
            System.IO.DirectoryNotFoundException
            System.IO.EndOfStreamException
            System.IO.FileLoadException
            System.IO.FileNotFoundException
            System.IO.PathTooLongException

<Serializable>
Public Class IOException   Inherits SystemException
[C#]
[Serializable]
public class IOException : SystemException
[C++]
[Serializable]
public __gc class IOException : public SystemException
[JScript]
public
   Serializable
class IOException extends SystemException

スレッドセーフ

この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。

解説

IOException は、ストリーム、ファイル、およびディレクトリを使用して情報にアクセスするときにスローされる例外の基本クラスです。

基本クラス ライブラリには、次の型が含まれています。それぞれの型は、 IOException の派生クラスです。

該当する場合は、IOException ではなくここで示した型を使用してください。

IOException は、値 0x80131620 の HRESULT COR_E_IO を使用します。

使用例

[Visual Basic, C#, C++] 次のコード例は FileStream.Lock メソッドの例の一部です。

 
' Catch the IOException generated if the 
' specified part of the file is locked.
Catch ex As IOException
    Console.WriteLine( _
        "{0}: The write operation could " & _
        "not be performed because the " & _
        "specified part of the file is " & _
        "locked.", ex.GetType().Name)
End Try

[C#] 
// Catch the IOException generated if the 
// specified part of the file is locked.
catch(IOException e)
{
    Console.WriteLine(
        "{0}: The write operation could not " +
        "be performed because the specified " +
        "part of the file is locked.", 
        e.GetType().Name);
}

[C++] 
// Catch the IOException* generated if the 
// specified part of the file is locked.
catch(IOException* e)
{
    Console::WriteLine(
        S"{0}: The write operation could not " 
        S"be performed because the specified " 
        S"part of the file is locked.", 
        e->GetType()->Name);
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

名前空間: System.IO

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET

アセンブリ: Mscorlib (Mscorlib.dll 内)

参照

IOException メンバ | System.IO 名前空間 | Exception | 例外の処理とスロー | 入出力操作 | ファイルからのテキストの読み取り | ファイルへのテキストの書き込み