private async void Button_Click_1(object sender, RoutedEventArgs e) {
try {
using (Stream stream = await GetWebPageAsync())
using (var fileStream = new FileStream(@"c:\apps\msg.bin", FileMode.Create)) {
await stream.CopyToAsync(fileStream);
StatusLabel.Content = "Done...";
}
}
catch (Exception ex) {
StatusLabel.Content = string.Format(
"An exception occured: {0}{1}Stack Trace:{1}{2}",
ex.Message,
Environment.NewLine,
ex.StackTrace
);
StatusLabel.Foreground = Brushes.Red;
}
}