在做ScreenSaver的StartKit时,RSS源总报无效。看错误是 程服务器返回错误: (407) 需要代理身份验证才明白原来是公司上网用的是代理:怎么样给WebClient加上代理呢?代码如下:下载RSS资源 1 /**//// <summary> 2 /// 根据一个指向有效的 RSS 2.0 XML 文件的 URI 构造 RSSFeed 对象的工厂。 3 /// </summary> 4 /// <exception cref="System.Net.WebException">当无法在 Web 上找到该 URI 时引发。</exception> 5 /// <param name="uri">从该处读取 RSS 源的 URI。</param> 6 public static RssFeed FromUri(string uri) 7 { 8 XmlDocument xmlDoc; 9 WebClient webClient = new WebClient();10 WebProxy webProxy = new WebProxy("192.168.0.3:8080");11 webProxy.Credentials = new System.Net.NetworkCredential("username,"password") webClient.Proxy = webProxy;13 using (Stream rssStream = webClient.OpenRead(uri))14 {15 TextReader textReader = new StreamReader(rssStream);16 XmlTextReader reader = new XmlTextReader(textReader);17 xmlDoc = new XmlDocument();18 xmlDoc.Load(reader);19 }20 return new RssFeed(xmlDoc);21 }