VB.NET Programming Examples: Email, Encryption, Zip, HTTP, XML, FTP

Chilkat Software Components

Save String to Unicode Text File

Back

VB.NET example code showing how to write Unicode to a file.
        ' Write the string as Unicode (2 bytes per character)
        ' This also writes the Unicode preamble at the beginning of the file.
        Dim appendMode As Boolean = False ' This overwrites the entire file.
        Dim sw As New StreamWriter("out_unicode.txt", appendMode, System.Text.Encoding.Unicode)
        sw.Write(TextBox1.Text)
        sw.Close()