1. 关键代码:
At any rate, the trick is to use the Windows Forms Webbrowser control. Contrary to what you may or may not have heard, this does not have to be situated on a container form - it can be used independently with 100% programmatic access. There are a couple of catches: First, being a Windows Form control, this must operate on an STA (Single Threaded Apartment) thread. This means you need to either set the "AspCompat = "true" attribute on the page that uses it, or you need to make the actual Webbrowser Navigate call to the target page on a secondary thread whose state has been set to STA. I chose the latter. The other gotcha is that the Webbrowser control does its navigation on more than one thread. The DocumentCompleted event handler is fired when the browser has fully loaded the target url, and therefore it is in this event that we want to do our business logic.
2. 示例程序下载