2
I need to capture an image of a printer in the /doc, write your bytes in a text file and save to another folder in the /doc.
How can I do that?
2
I need to capture an image of a printer in the /doc, write your bytes in a text file and save to another folder in the /doc.
How can I do that?
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 (My Documents), you can use the following code to fetch your image:
string pathToImage = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "nomeDaSuaImagem.jpg");
Note that I used an image .jpg
. If your image is in another format, change to the desired format, for example .png
, .bmp
, .gif
, etc..
Thank you very much. Solved my problem.
@Viniciusmarson Remembering that if the answer helped you, mark it as correct to help other people with the same problem!
Browser other questions tagged c#
You are not signed in. Login or sign up in order to post.
The correct thing is to write the bytes in a text file. An image (as well as any file) is a set of bytes.
– Jéf Bueno