Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 936
Iban Arriola Avatar asked Oct 03 '13 16:10

Iban Arriola


1 Answers

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.

like image 118
Jon Skeet Avatar answered Nov 08 '22 10:11

Jon Skeet