processexception.cs
来自「Csharp实例编程百例.rar」· CS 代码 · 共 32 行
CS
32 行
using System;
using System.IO;
public class ProcessException
{
public static void Main()
{
StreamWriter sw = null;
try
{
sw = new StreamWriter(new FileStream("Test.txt",FileMode.Open));
sw.WriteLine("Hello there");
Console.WriteLine("Message is written into file Test.txt");
}
catch(FileNotFoundException fnfe)
{
Console.WriteLine("File "+fnfe.FileName+" not found");
}
catch(Exception e)
{
Console.WriteLine(e);
}
finally
{
if (sw!=null)
{
sw.Close();
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?