Mega Code Archive

 
Categories / C# by API / System Net
 

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.rntsoft.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);             }         }     } }