C# WebClient的使用

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace WebClientExam
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            WebClient client = new WebClient();
            Stream s = client.OpenRead("http://www.163.com");
            StreamReader sr = new StreamReader(s);
            string line;
            while ((line = sr.ReadLine()) != null)
            {
                listBox1.Items.Add(line);
            }
            s.Close();


        }
    }
}
posted @ 2018-04-18 08:36  dxm809  阅读(461)  评论(0编辑  收藏  举报