System.Net.Webclient不工作“的WebClient”找不到 [英] System.Net.Webclient not working 'WebClient' could not be found
问题描述
我试图用WebClient的工作,但它给我的错误,所以我在几个论坛上检查(包括这一次),并在那里他们告诉把
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
在该文件的顶部:
using System.Net
和之后,我想使用Web客户端:
And after where I want use the WebClient:
WebClient webClient = new WebClient();
webClient.DownloadFile ("http://mysite.com/myfile.txt", @"c:\myfile.txt");
和我得到这个错误:
类型或命名空间名称'的WebClient'找不到(是否缺少using指令或程序集引用?)
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.
推荐答案
鉴于你的标签,这听起来像你可能会构建Windows商店应用 - 在这种情况下,你需要使用<一个HREF =http://msdn.microsoft.com/en-us/library/system.net.http.httpclient.aspx> 的HttpClient
代替 Web客户端
。
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
.
这篇关于System.Net.Webclient不工作“的WebClient”找不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!