title: VB code to convert text file to UTF16
body: <p>I am new to VB Code and struggling with Encode, Decode stuff. I need help with converting a text file from ANSI to UTF-16LE in VB.NET. This is what I have done so far. Later I am using BulkInsert for database operations and end up getting garbage data like</p>
  
  <blockquote>
    <p>∩┐╜000000000000000000000094409574896680&amp;∩┐╜</p>
  </blockquote>
  
  <p>which is supposed to be </p>
  
  <blockquote>
    <p>Ì095837491150000349192784421039109162%Î</p>
  </blockquote>
  
  <p>FYI, the database columns are NVARCHAR.</p>
  
  <pre><code>Dim sr As System.IO.StreamReader = New System.IO.StreamReader(filePath, System.Text.Encoding.Default)
  Dim sw As System.IO.StreamWriter = New StreamWriter(pPath &amp; pFilename &amp; "_TEMP", True, System.Text.Encoding.Unicode)
      While Not sr.EndOfStream
                  sw.writeLine(sr.readLine)
      End While
  sr.Close()
  sw.Close()
  </code></pre>
  
  <p>Could anyone help, please? Thanks.</p>