Search code examples
c#.netfile-uploadbitconverter

Byte[] to ASCII


I received the contents of a text file returned in binary values:

Byte[] buf = new Byte[size];
stream = File.InputStream;
stream.Read(buf, 0, size);

How can I convert this to ASCII?


Solution

  • Use:

    string str = System.Text.Encoding.ASCII.GetString(buf);