本文整理匯總了C#中System.Net.WebClient.DownloadString方法的典型用法代碼示例。如果您正苦於以下問題:C# WebClient.DownloadString方法的具體用法?C# WebClient.DownloadString怎麽用?C# WebClient.DownloadString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Net.WebClient
的用法示例。
在下文中一共展示了WebClient.DownloadString方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: WebClient.DownloadString(Uri u)
//引入命名空間
using System;
using System.IO;
using System.Net;
using System.Text.RegularExpressions;
class MainClass
{
private static void Main()
{
string remoteUri = "http://www.java2s.com";
WebClient client = new WebClient();
Console.WriteLine("Downloading {0}", remoteUri);
string str = client.DownloadString(remoteUri);
MatchCollection matches = Regex.Matches(str,@"http\S+[^-,;:?]\.htm");
foreach(Match match in matches)
{
foreach(Group grp in match.Groups)
{
string file = grp.Value.Substring(grp.Value.LastIndexOf('/')+1);
Console.WriteLine(file);
}
}
}
}
示例2: DownloadString
public static void DownloadString (string address)
{
WebClient client = new WebClient ();
string reply = client.DownloadString (address);
Console.WriteLine (reply);
}