C#从html中读取并输入到.Text中

本文关键字:输入 Text 读取 html | 更新日期: 2023-09-27 18:22:05

我目前正在尝试从在线托管的HTML文件中读取。我的代码应该读到最后,然后将xylosNotice1.Text更改为从HTML文件中读取的源代码。

以下是我尝试过的:

WebRequest req = HttpWebRequest.Create("http://www.example.com/UpdateMe/updates.html");
req.Method = "GET";
string source;
using (StreamReader reader = new StreamReader(req.GetResponse().GetResponseStream()))
{
    source = reader.ReadToEnd();
}
Console.WriteLine(source);
xylosNotice1.Text = (source);

它不会使用源更新文本框。

C#从html中读取并输入到.Text中

对不起,伙计们犯了一个愚蠢的错误,代码需要放在Main_Load部分,这已经解决了。