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


C# HttpClient.GetInputStreamAsync方法代码示例

本文整理汇总了C#中HttpClient.GetInputStreamAsync方法的典型用法代码示例。如果您正苦于以下问题:C# HttpClient.GetInputStreamAsync方法的具体用法?C# HttpClient.GetInputStreamAsync怎么用?C# HttpClient.GetInputStreamAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HttpClient的用法示例。


在下文中一共展示了HttpClient.GetInputStreamAsync方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConnectToClient

		/// <summary>
		/// Connects to client.
		/// </summary>
		/// <returns></returns>
		protected override async Task ConnectToClient()
		{
			using (HttpClient client = new HttpClient())
			{
				client.DefaultRequestHeaders.Authorization = new Windows.Web.Http.Headers.HttpCredentialsHeaderValue("Bearer", accessToken);
				using (var result = await client.GetInputStreamAsync(streamUri))
				{
					using (var s = result.AsStreamForRead())
					{
						await ListensToStreamAsync(s);
					}
				}
			}
		}
开发者ID:ParticleNET,项目名称:Particle-Windows-app,代码行数:18,代码来源:StreamEventManager.cs

示例2: downloadPdf

        private async void downloadPdf(String urlLink)
        {

           
            HttpClient client = new HttpClient();
            using (IInputStream inputStream = await client.GetInputStreamAsync(new Uri("http://www.viser.edu.rs/"+urlLink, UriKind.Absolute)))
            {
                Stream webStream = inputStream.AsStreamForRead();
                StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync("2.pdf", CreationCollisionOption.ReplaceExisting);

                //  StorageFile file = await Windows.ApplicationModel.Package.Current.InstalledLocation.CreateFileAsync("2.pdf",CreationCollisionOption.ReplaceExisting);

                Stream fileStream = await file.OpenStreamForWriteAsync();
                await webStream.CopyToAsync(fileStream);
                //MessageDialog md = new MessageDialog("File Saved");

                //await md.ShowAsync();
                webStream.Dispose();
                fileStream.Dispose();
            }
        }
开发者ID:nikolaz5,项目名称:DOT,代码行数:21,代码来源:MainPage.xaml.cs

示例3: getImage

 private async void getImage(object sender, object e)
 {
     var filter = new HttpBaseProtocolFilter();
     filter.CacheControl.ReadBehavior = HttpCacheReadBehavior.MostRecent;
     Uri BingImageXML = new Uri("http://cn.bing.com/HPImageArchive.aspx?idx=0&n=1");
     HttpClient LinkToBing = new HttpClient(filter);                            //加了filter才会刷新HttpClient的内容
     System.Xml.XmlDocument doc2 = new System.Xml.XmlDocument();
     var BingStream = await LinkToBing.GetInputStreamAsync(BingImageXML);
     doc2.Load(BingStream.AsStreamForRead());                                    //使用stream读取网页上的XML信息
     XmlNodeList lis=doc2.GetElementsByTagName("url");
     String str = lis[0].InnerText;
     imgUrl = new Uri("http://cn.bing.com" + str);
     BitmapImage BingBitmapImage = new BitmapImage(imgUrl);
     image.Source = BingBitmapImage;
 }
开发者ID:shenmintao,项目名称:Weather-UWP,代码行数:15,代码来源:MainPage.xaml.cs


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