本文整理汇总了C#中WebClient.OpenReadAsync方法的典型用法代码示例。如果您正苦于以下问题:C# WebClient.OpenReadAsync方法的具体用法?C# WebClient.OpenReadAsync怎么用?C# WebClient.OpenReadAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebClient
的用法示例。
在下文中一共展示了WebClient.OpenReadAsync方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DownloadTestsXap
private static void DownloadTestsXap(Uri testsXapUri, Action<StreamResourceInfo> OnDownloadComplete)
{
_onDownloadComplete = OnDownloadComplete;
WebClient wc = new WebClient();
wc.OpenReadCompleted += new OpenReadCompletedEventHandler(DownloadTestXap_Complete);
wc.OpenReadAsync(testsXapUri);
}
示例2: Play
public void Play(string filename, int song)
{
Filename = filename;
Song = song;
WebClient = new WebClient();
WebClient.OpenReadCompleted += WebClient_OpenReadCompleted;
WebClient.OpenReadAsync(new Uri(filename, UriKind.Relative));
}
示例3: GetVersionAsynch
public void GetVersionAsynch(string version,string token, string fullpath,bool test)
{
//string file = null;
string URL = "http://moscrif.com/ide/getVersion.ashx?v={0}";
client = new WebClient();
client.DownloadProgressChanged+= delegate(object sender, DownloadProgressChangedEventArgs e) {
//Console.WriteLine("----> {0}",e.ProgressPercentage);;
/*progressBar.Text = e.ProgressPercentage.ToString();
progressBar.QueueDraw();
while (Application.EventsPending ())
Application.RunIteration ();*/
};
if(String.IsNullOrEmpty(token)){
URL = String.Format(URL,version);
} else {
URL = String.Format(URL+"&t={1}",version,token);
}
//URL = String.Format(URL,version,token);
if(test){
URL = URL+"&test=1";
}
Console.WriteLine("URL ->{0}",URL);
//client.DownloadStringCompleted += delegate(object sender, DownloadStringCompletedEventArgs e) { //OpenReadCompleted += delegate(object sender, OpenReadCompletedEventArgs e) {//UploadStringCompleted+= delegate(object sender, UploadStringCompletedEventArgs e) {
client.OpenReadCompleted += delegate(object sender, OpenReadCompletedEventArgs e) {//UploadStringCompleted+= delegate(object sender, UploadStringCompletedEventArgs e) {
if (e.Cancelled){
isFinish = true;
return;
}
if (e.Error != null){
isFinish = true;
return;
}
if(File.Exists(fullpath))
File.Delete(fullpath);
FileStream writeStream = new FileStream(fullpath, FileMode.Create, FileAccess.Write);
try{
Copy(e.Result,writeStream);
writeStream.Close();
writeStream.Dispose();
}catch{
isError = true;
}
isFinish = true;
};
client.OpenReadAsync(new Uri(URL));
//client.DownloadStringAsync(new Uri(URL));
// while (Application.EventsPending ())
// Application.RunIteration ();
}