Saving image shown in web browser

六月ゝ 毕业季﹏ 提交于 2019-12-13 00:58:51

问题


Sorry for my bad English.

How can I save one of the images in my web Browser without redownload that image? Like ie 'Save

picture as' option? The browser has 'save picture as' in context menu but I want to save image

without using this option and want to save automatically. Thanks.


回答1:


Source here Here

IHTMLDocument2 doc = (IHTMLDocument2) webBrowser1.Document.DomDocument;
IHTMLControlRange imgRange = (IHTMLControlRange) ((HTMLBody) doc.body).createControlRange();

foreach (IHTMLImgElement img in doc.images)
{
     imgRange.add((IHTMLControlElement) img);

     imgRange.execCommand("Copy", false, null);

     using (Bitmap bmp = (Bitmap) Clipboard.GetDataObject().GetData(DataFormats.Bitmap))
     {
         bmp.Save(@"C:\"+img.nameProp);
     }
}


来源:https://stackoverflow.com/questions/21387235/saving-image-shown-in-web-browser

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!