How to convert image to binary and get result in text box

Posted by Ahmedsa under C# on 12/30/2016 | Points: 10 | Views : 325 | Status : [Member] | Replies : 1
I need to convert image to binary and get result in text box .

i using the following function :

Image found in path D:/person.jpg
public static byte[] ImageToBinary(string _path)  
{
FileStream fS = new FileStream(_path, FileMode.Open, FileAccess.Read);
byte[] b = new byte[fS.Length];
fS.Read(b, 0, (int)fS.Length);
fS.Close();
return b;
}

How to receive the value returned from function ImageToBinary in textbox1 ?

I work in c# windows form c#




Responses

Posted by: Allemahesh on: 1/2/2017 [Member] [MVP] Silver | Points: 25

Up
0
Down
As long as the value that you want to display as binary is an integer type (short, long, int, byte) then you can do:

txtFieldInBinary.Text = Convert.ToString(valueToDisplayAsBinary, 2);


Ahmedsa, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response