/*
C# Programming Tips & Techniques
by Charles Wright, Kris Jamsa
Publisher: Osborne/McGraw-Hill (December 28, 2001)
ISBN: 0072193794
*/
// FileOpen.cs -- Catches an exception that was thrown in a component
//
// Compile this program with the following command line:
// C:>csc /r:fopen.dll FileOpen.cs
//
namespace nsFileOpen
{
using System;
using System.IO;
class clsMain
{
static public void Main ()
{
clsFile file;
try
{
file = new clsFile ("");
}
catch (Exception e)
{
Console.WriteLine (e.Message);
Console.WriteLine ("Exception handled in client");
}
}
}
}
// Fopen.cs -- program to show exception handling in a component
//
// Compile this program with the following command line:
// C:>csc /t:library Fopen.cs
//
namespace nsFileOpen
{
using System;
using System.IO;
public class clsFile
{
FileStream strm;
public clsFile (string FileName)
{
strm = new FileStream (FileName, FileMode.Open,
FileAccess.Read);
}
}
}
|