HavocXphere
Honorary Master
Because I'm not used to languages with garbage collection I read up on it:
Here
And Here
Very nice. I also learned that I must Close() the StreamWriter myself or risk data loss. Fine. This causes a new problem though:
This fails to compile at SR.Close() with:
My option as far as I can see are:
Solutions? Or just accept it?
Thanks
Here
And Here
Very nice. I also learned that I must Close() the StreamWriter myself or risk data loss. Fine. This causes a new problem though:
Code:
try
{
StreamWriter SR = new StreamWriter(@"C:\testout.txt");
SR.WriteLine(@"Testing");
}
catch (Exception E)
{
Console.WriteLine(E.Message);
}
finally
{
SR.Close();
Console.Read();
}
This fails to compile at SR.Close() with:
Code:
The name 'SR' does not exist in the current context
My option as far as I can see are:
- Move the Close() to the try block <=== MSDN examples do this
- Move the new StreamWriter out of the try block
Solutions? Or just accept it?
Thanks