IOException Class
The exception that is thrown when an I/O error occurs.
For a list of all members of this type, see IOException Members.
System.Object
System.Exception
System.SystemException
System.IO.IOException
System.IO.DirectoryNotFoundException
System.IO.EndOfStreamException
System.IO.FileLoadException
System.IO.FileNotFoundException
System.IO.PathTooLongException
[Visual Basic] <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
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Remarks
IOException is the base class for exceptions thrown while accessing information using streams, files and directories.
The Base Class Library includes the following types, each of which is a derived class of IOException:
- DirectoryNotFoundException
- EndOfStreamException
- FileNotFoundException
- FileLoadException
- PathTooLongException
Where appropriate, use these types instead of IOException.
IOException uses the HRESULT COR_E_IO which has the value 0x80131620.
Example
[Visual Basic, C#, C++] This code example is part of a larger example provided for the FileStream.Lock method.
[Visual Basic] ' 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] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.IO
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework
Assembly: Mscorlib (in Mscorlib.dll)
See Also
IOException Members | System.IO Namespace | Exception | Handling and Throwing Exceptions | Working with I/O | Reading Text from a File | Writing Text to a File