最近在学习SilverLight,今天遇到了个问题,看到别人和msdn中WebClient类下有个DownloadStringCompleted ,而我在创建WebClient类之后去找不到他,哪位大侠知道请告诉我?
我的silverLight版本好像是3.0的
DownloadStringCompleted是WebClient 一个事件:
DownloadFileCompleted | 在异步文件下载操作完成时发生。 |
http://msdn.microsoft.com/zh-cn/library/system.net.webclient_events%28VS.80%29.aspx
首先确保是否引用了System.Net命名空间
//示例代码
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
Uri endpoint = new Uri("http://localhost/process.aspx");
WebClient wc = new WebClient();
wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
wc.DownloadStringAsync(endpoint);
}
void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
//your code here
}