im trying to create a text editor that when it presses the write now button it saves a text file to the C drive i have the variable declared to h old the value of what ever its suppose to hold but how do i make it create a text file and write to it? exact source code please
How to save the value of a string to a text file in VB2008?
I seriously suggest going with the RichTextBox control because it has the ability to SaveAs a RTF or TXT file. It also has a "Modified" property that lets you know if the RichTextBox text has been modified.
Example:
Me.RichTextBox1.SaveFile("C:\test.rtf"... RichTextBoxStreamType.RichText)
If you want to use a TextBox control then you could use the "System.IO.StreamWriter" class and write out each line.
Example:
Using writer As New System.IO.StreamWriter("C:\test.txt")
For Each line As String In Me.TextBox1.Lines
writer.WriteLine(line)
Next
End Using
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment