问题
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