Transform Byte Image?

2

I need to capture an image of a folder in / doc, write its bytes in a text file and save it to another folder in / doc.

How can I do this?

    
asked by anonymous 11.06.2018 / 13:58

1 answer

8

You can try the following:

// Carrega sua imagem e salva em um array de bytes
byte[] imgdata = System.IO.File.ReadAllBytes(@"C:\Test\simba.jpg");

// Salva seu array de bytes em um arquivo
System.IO.File.WriteAllBytes(@"C:\Test\byteArray.txt", imgdata);

If the folder is in My Documents , you can use the following code to get your image:

string pathToImage = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "nomeDaSuaImagem.jpg");

Note that I used a .jpg image. If your image is in another format, change to the desired format, such as .png , .bmp , .gif , etc.

    
11.06.2018 / 14:06