110,534
社区成员
发帖
与我相关
我的任务
分享
System.IO.Directory.GetFiles
string d = "http://120.*.*.171/SOFTUPDATE/";//你自己填自己ip地址,我这边根据截图随便填了已有的
System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
string z = "";
try
{
client.Timeout = TimeSpan.FromSeconds(3);//超时时间,这里根据网络情况自己考虑,我觉得3s足够了
z = client.GetAsync(d).Result.Content.ReadAsStringAsync().Result;
}
catch (Exception)
{
//throw;
}
var reg = @"(?is)<a[^>]*?href=(['""\s]?)(?<href>[^'""\s]*)\1[^>]*?>";
var mach = System.Text.RegularExpressions.Regex.Matches(z.ToLower(),reg,System.Text.RegularExpressions.RegexOptions.IgnoreCase);
foreach (System.Text.RegularExpressions.Match m in mach)
{
Console.WriteLine(m.Groups["href"].Value);//这就是每一个数据了,你自己处理不要的放到新的list或什么中就可以获取到你要的东西了。
}