'Visual Basic 2010 System.IO Excepties - IOExceptions Tekst Inlezen Van of Schrijven Naar een Bestand Module IOExceptionsExample Sub Main() Dim path As String = "..." Dim streamReader As System.IO.StreamReader Try streamReader = New System.IO.StreamReader(path) Try streamReader.ReadToEnd() ' or : streamReader.ReadLine() Catch ex As System.OutOfMemoryException ' there is insufficient memory to allocate a buffer for ' the returned string Catch ex As System.IO.IOException ' an I/O error occurs End Try Catch ex As System.ArgumentNullException ' path is null Catch ex As System.ArgumentException ' path is an empty string Catch ex As System.IO.FileNotFoundException ' the file cannot be found Catch ex As System.IO.DirectoryNotFoundException ' the specified path is invalid, such as being on an unmapped drive Catch ex As System.IO.IOException ' path includes an incorrect or invalid syntax for file name, ' directory name, or volume label Finally If streamReader IsNot Nothing Then streamReader.Close() End Try ' Dim streamWriter As System.IO.StreamWriter Try streamWriter = New System.IO.StreamWriter(path) Try streamWriter.Write("...") Catch ex As System.ObjectDisposedException ' AutoFlush is true or the buffer is full, and current writer ' is closed. Catch ex As System.NotSupportedException ' AutoFlush is true or buffer is full, and the contents of the ' buffer cannot be written to the underlying fixed size stream ' because the cursor is at the end the stream Catch ex As System.IO.IOException ' an I/O error occurs End Try Catch ex As System.UnauthorizedAccessException ' access is denied Catch ex As System.ArgumentNullException ' path is null Catch ex As System.ArgumentException ' path is an empty string ( "" ) or path contains the name of a ' system device (com1, com2, and so on) Catch ex As System.IO.DirectoryNotFoundException ' the specified path is invalid, such as being on an unmapped drive Catch ex As System.IO.PathTooLongException ' the specified path, file name, or both exceed the system-defined ' maximum length Catch ex As System.IO.IOException ' path includes an incorrect or invalid syntax for file name, ' directory name, or volume label syntax Catch ex As System.Security.SecurityException ' the caller does not have the required permission Finally If streamWriter IsNot Nothing Then streamWriter.Close() End Try ' Console.ReadLine() End Sub End Module 'Bezoek www.vbvoorbeelden.be voor meer Visual Basic voorbeelden. 'Copyright - De Wolf / vbvoorbeelden - 2003-2011 - Alle rechten voorbehouden.