日期:2014-05-16 浏览次数:20921 次
static void Main(string[] args)
{
FileStream f = null;
StreamWriter sw = null;
BinaryWriter bw = null;
try
{
f = File.Open(@"d:\xyz.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite);
sw = new StreamWriter(f);
bw = new BinaryWriter(f);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
finally
{
if(null != key)key.Close();
else Console.WriteLine("failed");
if (null != bw) bw.Close();
if (null != sw) sw.Close();//这句话出了exception
if (null != f) f.Close();
}
}
if (null != bw) bw.Close();
if (null != sw) sw.Close();