Пример #1
0
 private void cmdDownload_Click(object sender, RoutedEventArgs e)
 {
     if (lstFiles.SelectedIndex != -1)
     {
         // We must show SaveFileDialog now. We are not allowed to show it
         // when the web service returns the data, because the
         // DownloadFileCompleted event is not user-initiated.
         SaveFileDialog saveDialog = new SaveFileDialog();
         if (saveDialog.ShowDialog() == true)
         {
             // The second arugment passes the SaveFileDialog, so the
             // stream can be opened when the DownloadFileCompleted event
             // fires.
             // A nice side effect of this approach is that this code
             // allows the user to start multiple simultaneous downloads.
             client.DownloadFileAsync(lstFiles.SelectedItem.ToString(),
                                      saveDialog);
             lblStatus.Text = "Download started.";
         }
     }
 }