leora
leora

Reputation: 196499

in C#, how can i take an image from a URL and convert to System.Data.Linq.Binary

i am using a library that wants a photo in System.Data.Linq.Binary format. RIght now i just have a URL. what is the easiest way in C# to convert this link into the System.Data.Linq.Binary format?

Upvotes: 4

Views: 3304

Answers (2)

Oleks
Oleks

Reputation: 32323

I think WebClient.DownloadData is the easiest way:

var webClient = new WebClient();
var imageBytes = webClient.DownloadData(yourUrl);

Upvotes: 1

Marc Gravell
Marc Gravell

Reputation: 1062780

byte[] raw;
using(var client = new WebClient()) { // in System.Net
    raw = client.DownloadData(url);
}
var binary = new Binary(raw); // in System.Data.Linq

Upvotes: 7

Related Questions