FOLLOW US
softpcapps Software CODE HELP BLOG

Shareware and free Open Source Windows Software Applications and free Online Tools

How to Convert Binary to String

To convert a Binary string to its normal format you can do the following :
	

	public string BinaryToString(string enctxt)
	{ 	
		// use your encoding here
		Encoding  enc = System.Text.Encoding.UTF8;                

		string binaryString = enctxt.Replace(" ","");

		var bytes = new byte[binaryString.Length / 8];

		var ilen = (int)(binaryString.Length / 8);			                

		for (var i = 0; i < ilen; i++)
		{                                       
			bytes[i] = Convert.ToByte(binaryString.Substring(i*8, 8), 2);
		}

		string str = enc.GetString(bytes);

		return str;

	}