C
cj
my old code
Try
Dim sw As New System.io.StreamWriter(fileName, True)
sw.WriteLine(strToWrite)
sw.Close()
Catch
End Try
my new code
Using sw As New System.IO.StreamWriter(fileName, True)
sw.WriteLine(strToWrite)
End Using
If I have experience an exception in any part of the new code will using
prevent it from crashing the program? I don't think so. Do I need to
do this?
Using sw As New System.IO.StreamWriter(fileName, True)
try
sw.WriteLine(strToWrite)
catch
endtry
end using
What happens if sw As New System.IO.StreamWriter(fileName, True) throws
an exception? Can that line throw an exception?
P.S. Yes, I understand I'm just hiding the exception. That's how I need
it to work.
Try
Dim sw As New System.io.StreamWriter(fileName, True)
sw.WriteLine(strToWrite)
sw.Close()
Catch
End Try
my new code
Using sw As New System.IO.StreamWriter(fileName, True)
sw.WriteLine(strToWrite)
End Using
If I have experience an exception in any part of the new code will using
prevent it from crashing the program? I don't think so. Do I need to
do this?
Using sw As New System.IO.StreamWriter(fileName, True)
try
sw.WriteLine(strToWrite)
catch
endtry
end using
What happens if sw As New System.IO.StreamWriter(fileName, True) throws
an exception? Can that line throw an exception?
P.S. Yes, I understand I'm just hiding the exception. That's how I need
it to work.