HTMLAgilityPack을 사용하여 하나의 이미지를 얻은 다음 데이터베이스로 저장할 수 있도록 바이트로로드하려고합니다.
byte[] bIMG = File.ReadAllBytes(doc.DocumentNode.SelectSingleNode("//img[@class='image']").Attributes["src"].Value);
그러나 URI formats are not supported.
어떻게 내가 그걸 할 수 있니?
편집 : doc.DocumentNode.SelectSingleNode ( "// img [@ class = 'image']"). 속성 [ "src"]. 값 은 링크를 제공합니다 .
System.IO.File
클래스는 웹 URI를 읽을 수 없습니다.이 경우 WebClient를 사용할 수 있습니다.
byte[] imageAsByteArray;
using(var webClient = new WebClient())
{
imageAsByteArray = webClient.DownloadData("uri src");
}