G
garyusenet
Hello I'm trying to get to grips with variable scope.
I have a very basic programme i'm working on - and am once again being
confused by scope of variables.
I am just trying to write a new method which will read a file into a
text string. However I can't access my path/file variable as it is part
of another method.
The code for my program is here:
You can see the method i've started trying to write towards the end,
it's called 'ReadFile()' i attempted to write new StreamReader(path) on
the right hand side of the statement but as you can see that isn't
working. As i cant access the path variable i determined at
btnOpenFile_Click earlier in the programme, from the ReadFile() part of
my programme.
Can someone suggest the best way of me modifiying this code, so that I
can access the path variable. And also please explain the thinking
behind the modification.
I'm indebted for your help,
Gary.
I have a very basic programme i'm working on - and am once again being
confused by scope of variables.
I am just trying to write a new method which will read a file into a
text string. However I can't access my path/file variable as it is part
of another method.
The code for my program is here:
You can see the method i've started trying to write towards the end,
it's called 'ReadFile()' i attempted to write new StreamReader(path) on
the right hand side of the statement but as you can see that isn't
working. As i cant access the path variable i determined at
btnOpenFile_Click earlier in the programme, from the ReadFile() part of
my programme.
Can someone suggest the best way of me modifiying this code, so that I
can access the path variable. And also please explain the thinking
behind the modification.
I'm indebted for your help,
Gary.