您的位置:首页 > 理论基础 > 计算机网络

编写的第一个网络程序

2007-05-17 10:57 211 查看
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;

namespace WindowsApplication8
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
string string1 =textBox1.Text;
WebRequest wrq=WebRequest .Create("http://"+string1);
WebResponse wrs = wrq.GetResponse();
Stream strm = wrs.GetResponseStream();
StreamReader sr = new StreamReader(strm);
string line;
while ((line = sr.ReadLine()) != null)
{
listBox1.Items.Add(line);
}
strm.Close();
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: