webclient

WebClient construction overhead

微笑、不失礼 提交于 2019-12-10 12:35:30
问题 I have a client which makes a limited number of concurrent web requests. I use WebClient for this purpose. I currently have a pool of WebClient-s which I create once and use whichever one is idle. This approach is becoming a little cumbersome though, and I'm wondering if there is any benefit to having a collection of pre-constructed WebClient instances, or if creating them on the fly wouldn't be too much trouble? 回答1: Why on earth would you have a pool of WebClients in the first place? They

WebClient in Monotouch does not finish file downloads

荒凉一梦 提交于 2019-12-10 12:23:30
问题 I am finishing the development of an application using monotouch that downloads video files. Something like the TEDTalks app. But I am having the problem that the WebClient.DownloadFileAsync doesn't finish downloading the files reliably, but every so often hangs at some point and doesn't continue downloading the file. The problem is worst with larger files, although I have monitored the memory usage of the app and is not affected by size of the file being downloaded. The filestream that I

Using a WebClient to save an image with the appropriate extension

隐身守侯 提交于 2019-12-10 11:29:59
问题 I'm required to retrieve and save an image from a website to my local folder. The image type varies between .png, .jpg and .gif I've tried using string url = @"http://redsox.tcs.auckland.ac.nz/CSS/CSService.svc/"; string saveLoc = @"/project1/home_image"; using (var wc = new WebClient()) { wc.DownloadFile(url, saveLoc); } but this saves the file 'home_image' in the folder without the extension. My question is how do you determine the extension? Is there a simple way to do this? Can one use

Using special characters (slash) in FTP credentials with WebClient

橙三吉。 提交于 2019-12-10 11:28:58
问题 EDIT: I have discovered it's definitely the password that is causing issues. I have a forward slash in my password and cannot figure out how to get this to accept it. I've already tried replacing it with %5B . Changing the password is not a possibility. cd v: $username = "*********" $password = "*********" $usrpass = $username + ":" + $password $webclient = New-Object -TypeName System.Net.WebClient function ftp-test { if (Test-Path v:\*.204) { $files = Get-ChildItem v:\ -name -Include *.204 |

How to ignore certificate errors in Windows Phone 7?

僤鯓⒐⒋嵵緔 提交于 2019-12-10 10:54:25
问题 I have searched the internet and I know that in .Net we can use the following codes to ignore certification errors. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback( delegate { return true; } ); But the certification classes are not supported in windows phone 7 development (know from http://social.msdn.microsoft.com/Forums/en-US/windowsphone7series/thread/4f795a8e-de05-4f01-be7f-0cf2be3a71c2). I am now using a WebClient to visit a HTTPS website

Pass two JSON object by web client post method C#

蹲街弑〆低调 提交于 2019-12-10 09:54:16
问题 I need to pass below object as a parameter for a post method using web client method in C#. { "company": { "id": "e63dfcab345260b2591f585126ede56627db4ef2" }, "requestor": { "id": "", "email": "customer@example.com ", "firstName": "Test", "lastName": "Requestor", "role": "employerAdmin", "phone": "(415)1112222", "title": "HR Manager" } } I converted like this company[id]=e63dfcab345260b2591f585126ede56627db4ef2&requestor[id]=&requestor[email]=customer@example.com+&requestor[firstName]=Test

Should WebClient be used in a using statement?

蓝咒 提交于 2019-12-10 09:26:51
问题 If HttpClient is not supposed to be used in a using statement, see these links: https://aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/ http://www.nimaara.com/2016/11/01/beware-of-the-net-httpclient/ So if your not supposed to use HttpClient in a using statement then why do so many examples out there put WebClient in a using statement (including Microsoft); also I have not yet seen an article about not putting WebClient in a using statement? Eventually at the lowest level both

webclient methods not available to my Silverlight application

风格不统一 提交于 2019-12-10 09:20:26
问题 Trying to do basic webclient data pull in C#, and the methods are not available in visualstudio, and the code is not compiling. //snip WebClient client = new WebClient(); byte[] resp = client.DownloadData(url); //snip Error 1 'System.Net.WebClient' does not contain a definition for 'DownloadData' and no extension method 'DownloadData' accepting a first argument of type 'System.Net.WebClient' could be found (are you missing a using directive or an assembly reference?) C:\Users\Michael

detecting connection drops while WebClient is downloading a file asynchronously (in C#)

北城余情 提交于 2019-12-10 03:47:08
问题 I am using WebClient's DownloadFileAsync (in C#) method to download files asynchronously. I have event handlers attached to DownloadProgressChanged and DownloadFileCompleted events. I hoped to get notified of any errors through AsyncCompletedEventArgs's Error property in the DownloadFileCompleted event handler. It works well if the connection is not present before the download begins. It craps out with proper error and I get the error in the property I mentioned above. But if the connection

how to get a full html source?

北城余情 提交于 2019-12-09 21:19:27
问题 my name is loran and i'm using asp.net - c# in my project. i'm trying getting the exactly html source from a facebook page: (http://www.facebook.com/search.php?q=loranzur%40yahoo.com). i'm trying to get the id number into a string variable (in the source you can search for : Profile.php?id= ). i succeed to copy the source to a string variable using WebClient or HttpWebRequest, but the resaults is not the same as i open the "view source" by myself. the source that i copied to the the variable