简体   繁体   中英

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?

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

I think WebClient.DownloadData is the easiest way:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM