Read String from BinaryReader - CSharp System.IO

CSharp examples for System.IO:BinaryReader

Description

Read String from BinaryReader

Demo Code


using System.Text;
using System.IO;//www  . ja  v  a2  s . c  om
using System.Globalization;
using System;

public class Main{
        public static string ReadNtString(this BinaryReader br)
        {
            var sb = new StringBuilder();

            short ch;
            while (br.BaseStream.Position < br.BaseStream.Length && (ch = br.ReadInt16()) != 0)
                sb.Append((char)ch);

            return sb.ToString();
        }
}

Related Tutorials