System.Net.Webclient not working 'WebClient' could not be found

笑着哭i 提交于 2019-12-19 17:18:08

问题


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

In the top of the file:

using System.Net 

And after where I want use the 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?)

In the other forums the code that I just wrote above seems to be the solution but is not working for me.


回答1:


Given your tags, it sounds like you may be building a Windows Store app - in which case you need to use HttpClient instead of WebClient.



来源:https://stackoverflow.com/questions/19164900/system-net-webclient-not-working-webclient-could-not-be-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!