I getting one image with HTMLAgilityPack and then I want to load it as byte so I could save it in database.
byte[] bIMG = File.ReadAllBytes(doc.DocumentNode.SelectSingleNode("//img[@class='image']").Attributes["src"].Value);
But it says URI formats are not supported.
how else I can do that?
EDIT: doc.DocumentNode.SelectSingleNode("//img[@class='image']").Attributes["src"].Value gives a link
The System.IO.File
class can't read web URIs - you can use the WebClient for this:
byte[] imageAsByteArray;
using(var webClient = new WebClient())
{
imageAsByteArray = webClient.DownloadData("uri src");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With