2014-03-03 26 views
-2

當我使用的是DownloadStringAsync與Web客戶端的給我錯誤怎麼解決這個問題DownloadStringAsync返回錯誤,下載文件使用URL

private void BtnDownload_Click(object sender, RoutedEventArgs e) 
    { 
       //string PDFPath = ((((sender as Button).Content) as StackPanel).Children[1] as TextBlock).Text; 
       string PDFPath = "http://www.ncu.edu.tw/~ncu25352/Uploads/20131231103232738561744.pdf"; 
       pdffile = PDFPath; 

       WebClient wb = new WebClient(); 
       wb.DownloadStringCompleted += wb_DownloadStringCompleted; 
       wb.DownloadStringAsync(PDFPath,"pdfnamefile"); 
    } 

    void wb_DownloadStringCompleted(object sender, System.Net.DownloadStringCompletedEventArgs e) 
    { 
     throw new NotImplementedException(); 
    } 
+3

'它給我錯誤'非常有用的解釋.... –

回答

2

首先,你應該給我們確切的錯誤。

這個答案將假設你得到NotImplementedException

由於您自動生成wb_DownloadStringCompleted處理程序並且未刪除throw子句,您將收到此錯誤。

因此,只要下載完成,您自己就會發射一個NotImplementedException。有可能一切都很好。

試試這個代碼:

void wb_DownloadStringCompleted(object sender, System.Net.DownloadStringCompletedEventArgs e) 
{ 
    //What you want to do 
} 

並添加,當然您的指示。