/*--===------------------------------------------===---
WebClient测试
许明会 2007年12月9日 20:17:39
--===------------------------------------------===---*/
using System;
using System.Net;
namespace xumh
{
public class runMyApp
{
static void Main()
{
string strBaiduUri = @"http://www.baidu.com";
string strDownloadUri = @"http://microphoenix.spaces.live.com/feed.rss";
string strText=null;
WebClient wc = new WebClient();
try
{
System.IO.Stream response = wc.OpenRead(strBaiduUri);
int byteRead;
do
{
byteRead = response.ReadByte();
if(byteRead > 0)
strText += Convert.ToChar(byteRead);
}
while (byteRead > 0);
Console.WriteLine(strText);
//
wc.DownloadFile(strDownloadUri,@"C:\feed.rss");
Console.WriteLine("文件下载完成。");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
};
}
WebClient测试
许明会 2007年12月9日 20:17:39
--===------------------------------------------===---*/
using System;
using System.Net;
namespace xumh
{
public class runMyApp
{
static void Main()
{
string strBaiduUri = @"http://www.baidu.com";
string strDownloadUri = @"http://microphoenix.spaces.live.com/feed.rss";
string strText=null;
WebClient wc = new WebClient();
try
{
System.IO.Stream response = wc.OpenRead(strBaiduUri);
int byteRead;
do
{
byteRead = response.ReadByte();
if(byteRead > 0)
strText += Convert.ToChar(byteRead);
}
while (byteRead > 0);
Console.WriteLine(strText);
//
wc.DownloadFile(strDownloadUri,@"C:\feed.rss");
Console.WriteLine("文件下载完成。");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
};
}