当前位置: 首页>>代码示例>>C#>>正文


C# WebClient.OpenReadAsync方法代码示例

本文整理汇总了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);
 }
开发者ID:jschementi,项目名称:eggs,代码行数:7,代码来源:Eggs.cs

示例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));
 }
开发者ID:epi,项目名称:asap,代码行数:8,代码来源:SilverASAP.cs

示例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 ();
    }
开发者ID:moscrif,项目名称:ide,代码行数:61,代码来源:MainWindow.cs


注:本文中的WebClient.OpenReadAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。