>>>Hi Paul,
>>>
>>>>Also, I'd suggest putting the Close() in a Finally section of a Try/Catch.
>>>
>>>Why do I get a "Use of unassigned local variable "stream" in the finally section.
>>>
>
>It's because of this line:
>
>FileStream stream;
>
>You haven't assigned anything to it, so the compiler is complaining about it (it doesn't try to determine if it's assigned further down).
>
>Change it to:
>
>FileStream stream = null;
Hmm, originally I had:
FileStream stream = File.Create(xmlFileName); Inside the try along with the stream.Close and I had to put stream = null in the finally. I tried to fix it based on your post but it didn't like it. I moved the FileStream stream; before the try to see if that would work, but no joy.
Adding FileStream stream = null before the try does work. I am surprised since the initiialization was the first item in the try nothing could trip the catch except the stream. I guess we can't expect the compiler to know everything. I will take what I can get and this case it was easy.
Thanks Paul
Tim
Timothy Bryan