CSharp examples for System.IO:BinaryWriter
Write Unicode using BinaryWriter
using System.Text; using System.IO;/*ww w.ja v a 2 s. com*/ using System; public class Main{ public static void WriteUnicode(this BinaryWriter writer, string text, int len) { byte[] unicode = Encoding.Unicode.GetBytes(text); byte[] result = new byte[len * 2]; int max = len * 2 - 2; Array.Copy(unicode, result, unicode.Length > max ? max : unicode.Length); writer.Write(result); } }