当我使用带有webclient的DownloadStringAsync时,它给出了我如何解决这个问题的错误
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();
}
答案 0 :(得分:2)
首先,你应该给我们确切的错误。
这个答案假定你得到了NotImplementedException
。
您收到此错误是因为您自动生成了wb_DownloadStringCompleted
处理程序并且未删除throw
子句。
因此,只要下载完成,您就会自己解雇NotImplementedException
。事实上,一切都很好。
试试这段代码:
void wb_DownloadStringCompleted(object sender, System.Net.DownloadStringCompletedEventArgs e)
{
//What you want to do
}
然后添加你的说明。