当前位置 : 主页 > 网络编程 > net编程 >

c# webBrowser下载图片

来源:互联网 收集:自由互联 发布时间:2023-10-08
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { WebBrowser WebCtl = webBrowser1; HTMLDocument doc = (HTMLDocument)WebCtl.Document.DomDocument; HTMLBody body = (HTMLBody)doc.body; IHTMLCont
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{


WebBrowser WebCtl = webBrowser1;
HTMLDocument doc = (HTMLDocument)WebCtl.Document.DomDocument;
HTMLBody body = (HTMLBody)doc.body;
IHTMLControlRange rang = (IHTMLControlRange)body.createControlRange();
IHTMLControlElement Img = (IHTMLControlElement)webBrowser1.Document.Images[0].DomElement; //图片地址
Image oldImage = Clipboard.GetImage();
rang.add(Img);
rang.execCommand("Copy", false, null); //拷贝到内存
Image numImage = Clipboard.GetImage();
numImage.Save(string.Format("c:\\ID2\\{0}.jpg", ID));
string strID = ID--.ToString();
webBrowser1.Navigate(@"https://1.6.1.8/Image/?img=1&id=" + strID);


}





上一篇:c# runas
下一篇:没有了
网友评论