是否在.net中破坏了WebClient(在IE中配置了代理)?

时间:2011-01-28 20:57:59

标签: c# .net-4.0 webclient

以下代码使用在IE中配置的代理下载目标.net 2.0,3.0,3.5的yahoo网站文件。但它不适用于目标.net 4.我正在使用VS2010。怎么能在.net 4中打破?!

using System;    
using System.Net;    
using System.IO;

namespace PacProxyUsage
{

 /// <summary>    
 /// Summary description for ProxyTest.    
 /// </summary>

class ProxyTest
 {
  /// <summary>
  /// The main entry point for the application.
  /// </summary>
  [STAThread]
  static void Main(string[] args)
  {               
            string DestinationUrl = "http://www.yahoo.com";                

            try {
                WebClient wc = new WebClient();

                String s = wc.DownloadString(DestinationUrl);
                Console.WriteLine ( "Request was successful?"  + s);
            }catch ( Exception ex ){
                Console.WriteLine ( "Error: {0}", ex.Message );
            }finally{

            }
            Console.ReadLine();
  }
 }
}

0 个答案:

没有答案