-3

I am trying to convert an image to byte using c# and parsing the byte to a web service but I have this line of code I just can't get right. I am trying to point to a phone's storage path, pictures in my device and I can't seem to get the correct path.

byte[] imageByte = Environment.GetExternalStorageDirectory().getPath( "FAMScanner\\Vehicle_{0}.jpg");
J. Steen
  • 15,470
  • 15
  • 56
  • 63
Deeper
  • 1
  • 1
  • 2
    You know that `Environment.getExternalStorageDirectory().getPath()` returns a `String` right? Not a `byte[]`... – shkschneider Nov 27 '14 at 10:35
  • 1
    I'm curious. Isn't it *more* bothersome to capitalize every single word, rather than do what everyone else does and use sentence-casing? – J. Steen Nov 27 '14 at 10:50
  • What is `sentence-casing` ? I do not see capitalized words. So i cannot even ask who is doing that. – greenapps Nov 27 '14 at 11:21

2 Answers2

0

I'd suggest converting the image to a bitmap object first. Because that way you can use the following answer from another similar question.

Link to answer

To create a bitmap object you'll need to get the path to your image file first and then create it like that:

Bitmap bitmap = BitmapFactory.decodeFile(pathToImage)
Community
  • 1
  • 1
cgew85
  • 427
  • 3
  • 9
0

Thank you guys but i found the solution to my problem.

byte[] imageByte = System.IO.File.ReadAllBytes("/storage/sdcard0/Pictures/image.jpg");

thats all i needed to do to point directly to my android storage device in order to convert my image into a byte[] and parse it on a web service to a database.

Deeper
  • 1
  • 1