我编写了一个将下载的 HTML 文档设置到变量中的代码。但我不需要所有的 HTML 文档,只需要它的前 200 个字节。当它足够保存文档时,我需要取消方法'System.Net.WebClient.DownloadString'。
try
{
WebClient webClient = new WebClient();
html = webClient.DownloadString("https://example.com/index.html");
} catch(Exception e) {
MessageBox.Show(e.Message);
}