Click here to Skip to main content
16,004,854 members
Home / Discussions / C#
   

C#

 
AnswerRe: How can I compare two points in C#? Pin
Luc Pattyn16-Jan-07 5:50
sitebuilderLuc Pattyn16-Jan-07 5:50 
QuestionEstablishing Relationship with tables in SQL Server 2000 Pin
Banjo Ayorinde16-Jan-07 4:33
Banjo Ayorinde16-Jan-07 4:33 
AnswerRe: Establishing Relationship with tables in SQL Server 2000 Pin
Colin Angus Mackay16-Jan-07 4:47
Colin Angus Mackay16-Jan-07 4:47 
QuestionCreating Report with Crystal Report based on SQL 2000 Pin
Banjo Ayorinde16-Jan-07 4:26
Banjo Ayorinde16-Jan-07 4:26 
Questionvisual style Pin
fmardani16-Jan-07 4:26
fmardani16-Jan-07 4:26 
QuestionBindingSource with Combo - how to clear the combo intiailly Pin
Umair Ahmad16-Jan-07 4:22
Umair Ahmad16-Jan-07 4:22 
QuestionAccess Remote Registry using WMI:StdRegProv Pin
Parrish16-Jan-07 4:14
Parrish16-Jan-07 4:14 
Questioncan't access object in finally-block [solved] Pin
Drum D.16-Jan-07 3:58
Drum D.16-Jan-07 3:58 
I've got a problem with the following piece of code
Boolean retval = false;

StreamReader sr;

try
{
    sr = new StreamReader(new FileStream(filename, FileMode.Open, FileAccess.Write));
    sr.Close();
    retval = true;
}
catch (FileNotFoundException e)
{
    el.WriteEntry("Die Datei " + filename + " existiert nicht.", EventLogEntryType.Error);
}
catch (ArgumentException e)
{
    Console.WriteLine("Der Stream konnte nicht gelesen werden.");
}
catch (IOException e)
{
    //Datei ist noch nicht fertig geschrieben.
    Console.WriteLine("Datei noch nicht fertig geschrieben.");
    return false;
}
finally
{
    sr.Close();

    return retval;
}


I can't access sr in the finally block. Why is that so? I thought try ... catch ... finally would make one construct. Same happens if I don't declare sr before the try.


-- modified at 4:12 Wednesday 17th January, 2007
AnswerRe: can't access object in finally-block Pin
Pete O'Hanlon16-Jan-07 4:17
mvePete O'Hanlon16-Jan-07 4:17 
AnswerRe: can't access object in finally-block Pin
J4amieC16-Jan-07 5:09
J4amieC16-Jan-07 5:09 
AnswerRe: can't access object in finally-block Pin
Drum D.16-Jan-07 7:33
Drum D.16-Jan-07 7:33 
QuestionScope_identity() doesn't work Pin
cruscotto16-Jan-07 3:45
cruscotto16-Jan-07 3:45 
AnswerRe: Scope_identity() doesn't work Pin
Dave Kreskowiak16-Jan-07 5:51
mveDave Kreskowiak16-Jan-07 5:51 
GeneralRe: Scope_identity() doesn't work Pin
cruscotto16-Jan-07 6:08
cruscotto16-Jan-07 6:08 
GeneralRe: Scope_identity() doesn't work Pin
Dave Kreskowiak16-Jan-07 8:06
mveDave Kreskowiak16-Jan-07 8:06 
Questionhelp!! replace string Pin
vanudu16-Jan-07 3:42
vanudu16-Jan-07 3:42 
AnswerRe: help!! replace string Pin
Pete O'Hanlon16-Jan-07 3:47
mvePete O'Hanlon16-Jan-07 3:47 
GeneralRe: help!! replace string Pin
vanudu16-Jan-07 3:48
vanudu16-Jan-07 3:48 
GeneralRe: help!! replace string Pin
Pete O'Hanlon16-Jan-07 3:56
mvePete O'Hanlon16-Jan-07 3:56 
GeneralRe: help!! replace string Pin
vanudu16-Jan-07 4:02
vanudu16-Jan-07 4:02 
GeneralRe: help!! replace string Pin
Pete O'Hanlon16-Jan-07 4:15
mvePete O'Hanlon16-Jan-07 4:15 
AnswerRe: help!! replace string Pin
Seishin#16-Jan-07 3:49
Seishin#16-Jan-07 3:49 
GeneralRe: help!! replace string Pin
vanudu16-Jan-07 3:58
vanudu16-Jan-07 3:58 
GeneralRe: help!! replace string Pin
Dave Kreskowiak16-Jan-07 5:53
mveDave Kreskowiak16-Jan-07 5:53 
AnswerRe: help!! replace string Pin
saud_a_k16-Jan-07 3:50
saud_a_k16-Jan-07 3:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.