This procedure will perform a specific Try, Catch looking for any IO related errors Use the FileStream class from the System.IO Namespace (see Imports at top of file) This command will fail if the file does not exist.Will catch any generic IO exception You could use the StringWriter to build a multi-line string in memory. However, it's overkill for this simple message. FYI StringWriter comes from the System.IO Namespace. Accessing an exception objects StackTrace could cause an exception thus we need to wrap the call in its own Try, Catch block. This catch will trap any error unexpected error.
When you run the example from within Visual Studio .NET, the debugger will be invoked via breakpoints for each button. You can selectively turn the breakpoints on and off by using the Breakpoints Window, accessible via the Debug | Windows | Breakpoints menu command or the CTRL+ALT+B keystroke.
In the code samples, the new .NET Framework version of MsgBox (MessageBox from the System.Windows.Forms namespace) is used. In Visual Basic .NET applications, MsgBox will continue to work fine. However, C# and other languages do not expose MsgBox. Use MessageBox instead in those cases.