How to send VBCrLF the .net way?

p_nivalis

Active member
Joined
Oct 1, 2004
Messages
33
Programming Experience
5-10
Hello all,

I am having difficulty sending the mentioned keycode during a file write. What I am trying to do is open a text file, loop through a collection, writing each keypair on it's own line.

For example:
12345#Foobar
54321#Barfoo
etc.

I know I could use the old VB namespace and use VbCrLf, but I am trying to make the app pure .net.

Currently, this is the code I am using:

VB.NET:
Public Sub WriteDB()
 
' Delete the original file first
IO.File.Delete(Application.StartupPath & "\" & STR_DB_FILENAME)
 
' Create an instance of StreamWriter to write text to a file.
Using sw As IO.StreamWriter = New IO.StreamWriter(Application.StartupPath & "\" & STR_DB_FILENAME, True)
 
Dim itm As KeyValuePair(Of String, String)
 
' Loop through the dictDBList collection adding each item to the .db file
For Each itm In dictDBList
 
sw.Write(itm.Key & STR_DB_DELIMITER & itm.Value)
 
Next
 
sw.Close()
 
End Using
 
End Sub


That places everythign into one long line. Now if I change it to: sw.Write(itm.Key & STR_DB_DELIMITER & itm.Value & keys.linefeed) (or keys.return, or console.enter, they all just add the character code as a sting, to the text rather than actually do the requested action in the file.

Can someone tell me how to get it to do the requested action instead?

Thanks in advance =)
 
Last edited by a moderator:
I think it's System.Environment.NewLine

-tg
 

Latest posts

Back
Top