简体   繁体   English

无法找到System.Net.Webclient无法正常工作的'WebClient'

[英]System.Net.Webclient not working 'WebClient' could not be found

I am trying to work with WebClient but it is giving me errors so I check in several forums (included this one) and they where telling to put 我正在尝试使用WebClient,但它给了我错误,所以我检查了几个论坛(包括这个)和他们在哪里告诉放

In the top of the file: 在文件的顶部:

using System.Net 

And after where I want use the WebClient: 在我想要使用WebClient之后:

 WebClient webClient = new WebClient();
 webClient.DownloadFile ("http://mysite.com/myfile.txt", @"c:\myfile.txt");

And I get this error: 我收到这个错误:

The type or namespace name 'WebClient' could not be found (are you missing a using directive or an assembly reference?) 找不到类型或命名空间名称'WebClient'(您是否缺少using指令或程序集引用?)

In the other forums the code that I just wrote above seems to be the solution but is not working for me. 在其他论坛中,我刚才写的代码似乎是解决方案但不适合我。

鉴于您的标签,听起来您可能正在构建Windows应用商店应用 - 在这种情况下,您需要使用HttpClient而不是WebClient

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM