johnabraham101 wrote:
I've already posted a thread with the same problem but
couldn't satisfactory answer. Let's come to the point.
I can write some text to a text file with WriteAllText method.
Short answer - Environment.New Line will add a line break into your file.
Longer answer -
WriteAllText() is what I call a "convenienc e method"; it wraps up lots
of other stuff and, so long as it does everything the way you want, all
well and good.
However, I suspect you're reaching a point where it's /not quite/
fitting your requirements any more and you need something else.
Here's another way ...
Dim sw as New StreamWriter( "file", False )
sw.WriteLine( "This text should be written in 1st line of c:\test.txt" )
sw.WriteLine( "This text should be written in 2nd line of c:\test.txt" )
sw.Close()
The StreamWriter class sports other useful methods that may help you in
your file creation as well, for example:
Dim sw as New StreamWriter( "file", False )
For iSub as Integer = 1 to 10
sw.Write( "Line " )
sw.Write( iSub.ToString() )
sw.WriteLine( " of 10" )
Next
sw.Close()
HTH,
Phill W.