download file c# e xaml

https://msdn.microsoft.com/en-us/library/windows/apps/xaml/jj152726.aspx

private async void Download()
{
try
{
String feed = "http://www.ultrarss.net/feeds/novelas.json";
System.Net.Http.HttpClient Webclient = new System.Net.Http.HttpClient();
Webclient.MaxResponseContentBufferSize = 256000;
// Webclient.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0");
HttpResponseMessage response = await Webclient.GetAsync(feed);
response.EnsureSuccessStatusCode();
responseBodyAsText = await response.Content.ReadAsStringAsync();
tb1.Text = responseBodyAsText;
}
catch (HttpRequestException hre)
{
tb1.Text = hre.ToString();
}
catch (Exception ex)
{
// For debugging
tb1.Text = ex.ToString();
}
}

Nenhum comentário:

Postar um comentário