I have the following code in Visual Studio 2005.
Dim OutFile As System.IO.StreamWriter Try OutFile = New System.IO.StreamWriter(Filename) // Do stuff with OutFile Catch Ex As Exception // Handle Exception Finally If OutFile IsNot Nothing Then OutFile.Close() End Try
But VS2005 brings up the warning for the line ‘If OutFile IsNot..’ that
Variable ‘OutFile’ is used before it has been assigned a value. A null reference exception could result at runtime.
Is there some way of removing this warning by subtly altering the code or is there just a better way of doing what I’m trying to do?
Thanks
Rob
Similar to C# error: Use of unassigned local variable