C# 如何获取给定网址的所有aspx页面列表

C# 如何获取给定网址的所有aspx页面列表,c#,asp.net,C#,Asp.net,我想创建一个包含在我的网站中的所有aspx页面的列表 但我只有40页。但是有2000多页 请告诉我如何获得所有的aspx页面列表。 我正在使用以下代码获取url页面列表 private string[] GetAllUrls(string str) { string pattern = @"<a.*?href=[""'](?<url>.*?)[""'].*?>(?<name>.*?)</a>"; System.Text.Reg

我想创建一个包含在我的网站中的所有aspx页面的列表

但我只有40页。但是有2000多页

请告诉我如何获得所有的aspx页面列表。 我正在使用以下代码获取url页面列表

private string[] GetAllUrls(string str) 
{ 
    string pattern = @"<a.*?href=[""'](?<url>.*?)[""'].*?>(?<name>.*?)</a>";

    System.Text.RegularExpressions.MatchCollection matches = System.Text.RegularExpressions.Regex.Matches(str, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase); 
    string[] matchList = new string[matches.Count]; 
    int c = 0; 

    foreach (System.Text.RegularExpressions.Match match in matches) 
        matchList[c++] = match.Groups["url"].Value; return matchList; 
}
private string[]GetAllUrls(string str)
{ 
字符串模式=@“”;
System.Text.RegularExpressions.MatchCollection matches=System.Text.RegularExpressions.Regex.matches(str、pattern、System.Text.RegularExpressions.RegexOptions.IgnoreCase);
string[]matchList=新字符串[matches.Count];
int c=0;
foreach(System.Text.RegularExpressions.Match中的匹配)
matchList[c++]=match.Groups[“url”].Value;返回matchList;
}

我不知道您是如何获得这40个文件的,但您可以这样做:

String[] Files = Directory.GetFiles("C:\\YourSorceCodeDirectory", "*.aspx", SearchOption.AllDirectories);

你怎么知道有2000页?你怎么知道那40页?显示您尝试过的内容。请粘贴代码,以了解您尝试如何操作私有字符串[]GetAllUrls(string str){string pattern=@'';System.Text.RegularExpressions.MatchCollection matches=System.Text.RegularExpressions.Regex.matches(str,pattern,System.Text.RegularExpressions.RegexOptions.IgnoreCase);string[]匹配列表=新字符串[matches.Count];int c=0;foreach(System.Text.RegularExpressions.Match-in-matches)匹配列表[c++]=Match.Groups[“url”].Value;返回匹配列表;}我正在使用上面的代码获取url。感谢Lukinha RS,但我想从服务器而不是本地计算机检索所有url。我已获取。但此代码将从服务器进行搜索。如果您的web应用程序在服务器中发布,则此“C:\”将成为您的服务器搜索驱动器。