日期:2014-05-17 浏览次数:21197 次
private bool CheckProxy(string Url, string ProxyAddr, string ProxyUser, string ProxyPassWord, string ProxyDomain)
{
try
{
WebProxy CurrentWebProxy = new WebProxy(ProxyAddr, true);
if (ProxyPassWord.Trim().Length > 0 && ProxyUser.Trim().Length > 0)
CurrentWebProxy.Credentials = new System.Net.NetworkCredential(ProxyUser, ProxyPassWord, ProxyDomain);
else
CurrentWebProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
WebRequest sr = WebRequest.Create(Url);
sr.Proxy = CurrentWebProxy;
sr.GetResponse();
return true;
}
catch (Exception ee)
{
LogFile("代理服务器状态检测: 代理地址:" + ProxyAddr + " 用户名:" + ProxyUser + " 密码:" + ProxyPassWord + " 域:" + ProxyDomain + " 异常信息:" + ee.Message);