老外编的程序(二)--System.Net的示例程序

来源:互联网 发布:win8修改mac地址 编辑:程序博客网 时间:2024/06/05 23:29
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
using System;
using System.Net;
using System.Text;
using System.Collections.Specialized;

public class WebClientSample
{
    public static void Main()
    {
        try {
            
        // Download the data to a buffer
               WebClient client = new WebClient();

          Byte[] pageData = client.DownloadData("http://www.microsoft.com");
        string pageHtml = Encoding.ASCII.GetString(pageData);
        Console.WriteLine(pageHtml);

        // Download the data to a file
                client.DownloadFile("http://www.bn.com", "page.htm");

        // Upload some form post values
        NameValueCollection form = new NameValueCollection();        
        form.Add("MyName", "MyValue");        
        Byte[] responseData = client.UploadValues("http://localhost/somefile.aspx", form);        

        }
        catch (WebException webEx) {
              Console.WriteLine(webEx.ToString());
               if(webEx.Status == WebExceptionStatus.ConnectFailure) {
                   Console.WriteLine("Are you behind a firewall?  If so, go through the proxy server.");
               }
        }
    }       &n

老外编的程序(二)--System.Net的示例程序';return true">
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击