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?
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?
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.