WebClient下载字符串(几个字符页面)太慢了 [英] WebClient download string (a few chars page) is so slow
本文介绍了WebClient下载字符串(几个字符页面)太慢了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从URL下载字符串.不幸的是,它非常慢.
I am trying to download a string from an URL. Unfortunately, it is very slow.
这是我的代码:
// One of these types for two bad solutions anyway
// byte[] result = new byte[12];
// string result;
using (var webClient = new System.Net.WebClient())
{
String url = "http://bg2.cba.pl/realmIP.txt";
//result = webClient.DownloadString(url); // slow as hell
//webClient.OpenRead(url).Read(result, 0, 12); // even slower
}
大约需要4-5秒,这对我来说似乎是不合适的...
It takes about 4-5 seconds, which seems very inappropriate to me...
此网址的内容为IP
XX.YYY.ZZ.FF
推荐答案
已修复,很抱歉,我想将此问题放在此处,但是...这是工作代码
Fixed, sorry for putting this question here I guess, but... here is working code
string result;
using (var webClient = new System.Net.WebClient())
{
webClient.Proxy=null;
String url = "http://bg2.cba.pl/realmIP.txt";
result = webClient.DownloadString(url);
}
只需将Proxy设置为null
Just set Proxy to null
这篇关于WebClient下载字符串(几个字符页面)太慢了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文