Questions tagged [webclient]

WebClient is a class for .NET Framework applications that provides methods for sending and receiving data from a resource identified by a URI.

Read more about the WebClient class and its usage here: https://learn.microsoft.com/en-us/dotnet/api/system.net.webclient

4098 questions
19
votes
8 answers

How to get an HTML file using Python?

I am not very familiar with Python. I am trying to extract the artist names (for a start :)) from the following page: http://www.infolanka.com/miyuru_gee/art/art.html. How do I retrieve the page? My two main concerns are; what functions to use and…
nakiya
  • 14,063
  • 21
  • 79
  • 118
19
votes
2 answers

How to use HttpClient without async

Hello I'm following to this guide static async Task GetProductAsync(string path) { Product product = null; HttpResponseMessage response = await client.GetAsync(path); if (response.IsSuccessStatusCode) { product =…
Kumar J.
  • 193
  • 1
  • 1
  • 5
19
votes
4 answers

Deleting file from FTP in C#

My program can upload files into an FTP server using this code: WebClient client = new WebClient(); client.Credentials = new System.Net.NetworkCredential(ftpUsername, ftpPassword); client.BaseAddress = ftpServer; client.UploadFile(fileToUpload,…
user2399117
  • 303
  • 1
  • 2
  • 5
18
votes
1 answer

WebClient class doesn't exist in Windows 8

I want to use a HTTP webservice, and I've already developed an app for wp7. I use the WebClient class, but I can not use it for windows 8 ("error: type or namespace can not be found"). What else can I use? Can you provide me a sample of code? Does…
NicoMinsk
  • 1,716
  • 6
  • 28
  • 53
18
votes
1 answer

Handling two WebException's properly

I am trying to handle two different WebException's properly. Basically they are handled after calling WebClient.DownloadFile(string address, string fileName) AFAIK, so far there are two I have to handle, both WebException's: The remote name could…
baron
  • 11,011
  • 20
  • 54
  • 88
18
votes
6 answers

Read response header from WebClient in C#

I'm trying to create my first windows client (and this is my fist post her), there shall communicate with a "web services", but i have some trouble to read the response header there is coming back. In my response string do I received a nice JSON…
user3352795
  • 181
  • 1
  • 1
  • 3
17
votes
9 answers

Read file from FTP to memory in C#

I want to read a file from a FTP server without downloading it to a local file. I wrote a function but it does not work: private string GetServerVersion() { WebClient request = new WebClient(); string url = FtpPath + FileName; string…
Mselmi Ali
  • 327
  • 1
  • 4
  • 7
17
votes
1 answer

Maximum concurrent requests for WebClient, HttpWebRequest, and HttpClient

Are there any limit to how many concurrent/parallel requests you can send using WebClient, HttpWebRequest, and HttpClient class in .NET 4.5? Or is it that you can send unlimited parallel requests if there is no restriction on the web API or…
Chenlei Shen
  • 175
  • 1
  • 1
  • 5
17
votes
2 answers

WebClient DownloadString UTF-8 not displaying international characters

I attempt to save the html of a website in a string. The website has international characters (ę, ś, ć, ...) and they are not being saved to the string even though I set the encoding to be UTF-8 which corresponds to the websites charset. Here is my…
mrybak3
  • 385
  • 1
  • 3
  • 14
17
votes
4 answers

Requesting html over https with c# Webclient

I am attempting various html resources via c# WebClient class from a site I have no control over. When I attempt to access urls such as "https://archive.org/details/OTRR_In_The_Name_Of_The_Law_Singles" I get the error: System.Net.WebException:…
RRadix
  • 171
  • 1
  • 1
  • 4
17
votes
3 answers

Accept Cookies in WebClient?

I just started experimenting with C# WebClient. What I have is the code below which gets html code from a website and writes it in a .txt file. The only problem I have is that some websites require you to accept cookies before you can use the…
MeesterPatat
  • 2,671
  • 9
  • 31
  • 54
16
votes
2 answers

Getting the upload progress during file upload using Webclient.Uploadfile

I have an app that uploads files to server using the webclient. I'd like to display a progressbar while the file upload is in progress. How would I go about achieving this?
Bruce Adams
  • 12,040
  • 6
  • 28
  • 37
16
votes
5 answers

Is there any way to monitor the progress of a download using a WebClient object in powershell?

I'm downloading a file using a simple line like this: $webclient = New-Object -TypeName System.Net.WebClient $webclient.DownloadFile("https://www.example.com/file", "C:/Local/Path/file") The problem is that I want to display a message to the user…
EGr
  • 2,072
  • 10
  • 41
  • 61
16
votes
2 answers

Send file+parameters in post request

I'm using this code to send parameters to a webpage and getting correct response from it. System.Net.WebClient oWeb = new System.Net.WebClient(); oWeb.Proxy = System.Net.WebRequest.DefaultWebProxy; oWeb.Proxy.Credentials =…
m.qayyum
  • 401
  • 2
  • 15
  • 44
15
votes
2 answers

Send POST with WebClient.DownloadString in C#

I know there are a lot of questions about sending HTTP POST requests with C#, but I'm looking for a method that uses WebClient rather than HttpWebRequest. Is this possible? It'd be nice because the WebClient class is so easy to use. I know I can set…
PorkWaffles
  • 183
  • 1
  • 2
  • 7