I am using VS 2008 (C#)... I have created a function in a GlobalClass to use it globally.. This is for opening a dialog box. When I call this function in my method it works but
How do I use a variable declared in a method, outside that method?
You can't. You can move the declaration to outside the method. Then it becomes a field of the containing class.
But as many others have said, in this case it's better to return the filename.
The only things a method "exhibits" to the outside world, are the parameters (it might mutate the objects they reference; or assign to them if they're ref or out) and the return value.