I have been reading this as I would like to do this via LINQ. However, I have been unable to figure out how to read the data from the API.
When I output resource.Data.Body
it says, Byte[]
.
When I output resource.Data.Size
it says, 834234822
. (or something like that)
I am trying to save the contents into my database like this:
newContent.ATTACHMENT = resource.Data.Body;
However, no data is ever loaded. I assume I have to loop through Body
and store the contents in a variable, but I am not sure how.
Can someone help me connect the dots here?
Edit:
This is the source of the binary data I am trying to read http://dev.evernote.com/start/core/resources.php
Edit 2:
I am using the following code which gives me binary data and saves to database, but it must be corrupt, or something because when I go to open the file Windows photo viewer says it's corrupt or too large...
Resource resource = noteStore.getResource(authToken, attachment.Guid, true, false, true, true);
StringBuilder data = new StringBuilder();
foreach(byte b in resource.Data.Body)
{
data.Append(Convert.ToString(b, 2).PadLeft(8, '0'));
}
...
newContent.ATTACHMENT = System.Text.Encoding.ASCII.GetBytes(data.ToString());