[RESOLVED] Declaration expected
Hello
I have added a new windows form to the project and put in the lines (see below) BUT this line here:
Code:
mywriterdefaultsettings.WriteLine("TWO")
generates an error "Declaration expected"
Any idea as to the cure?
Thank you.
Code:
Public Class defaultsettings
Dim thestringstart2 As String = ""
Dim thestringend2 As String = "defaultsettings.txt"
Dim thefilepath2 As String = thestringstart2 & thestringend2
Dim myfilestream2 As New System.IO.FileStream(thefilepath2, IO.FileMode.Append, IO.FileAccess.Write)
Dim mywriterdefaultsettings As New System.IO.StreamWriter(myfilestream2)
mywriterdefaultsettings.WriteLine("TWO")
End Class
Re: [RESOLVED] Declaration expected
I would be inclined to declare those IO objects at the class level but actually create them in a constructor. Generally it's good practice to perform IO operations within a Try block in case there are any issues, and you can't do that outside a method.
Re: [RESOLVED] Declaration expected
Blimey, jmcilhinney, you certainly know your stuff!