WebClient类

Video.wmv在ClientBin目录下:

代码
   
     
void Page_Loaded( object sender, RoutedEventArgs e)
{
WebClient client
= new WebClient();
client.DownloadProgressChanged
+= new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
client.OpenReadCompleted
+= new OpenReadCompletedEventHandler(client_OpenReadCompleted);
client.OpenReadAsync(
new Uri( " Video.wmv " , UriKind.Relative));
}

void client_OpenReadCompleted( object sender, OpenReadCompletedEventArgs e)
{
try
{
myMedia.SetSource(e.Result);
myMedia.Play();
}
catch
{
myStatus.Text
= " Terribly Error! " ;
}

}

void client_DownloadProgressChanged( object sender, DownloadProgressChangedEventArgs e)
{
myStatus.Text
= string .Format( " Progress of {0}% " , e.ProgressPercentage);
System.Threading.Thread.Sleep(
100 );
}

 

你可能感兴趣的:(client)