显示网页HTML源代码
1)引入命名空间
2)添加一个button,一个textbox,一个listbox

3)加入button事件
using System.Net;
using System.IO;
using System.IO;
2)添加一个button,一个textbox,一个listbox
3)加入button事件
1
private void button1_Click(object sender, EventArgs e)
2
{
3
string netUrl = "http://"+textBox1.Text;
4
string line;
5
WebClient client = new WebClient();
6
Stream strm = client.OpenRead(netUrl);
7
StreamReader sr = new StreamReader(strm);
8
9
while((line=sr.ReadLine())!=null)
10
{
11
listBox1.Items.Add(line);
12
}
13
strm.Close();
14
}

2

3

4

5

6

7

8

9

10

11

12

13

14
