0
可能重复:
How can i get a string and return each time a string from array?如何返回目录列表而不是网址?
我有这样的功能:
private List<string> getLinks(HtmlAgilityPack.HtmlDocument document)
{
List<string> mainLinks = new List<string>();
var linkNodes = document.DocumentNode.SelectNodes("//a[@href]");
if (linkNodes != null)
{
foreach (HtmlNode link in linkNodes)
{
var href = link.Attributes["href"].Value;
if (href.StartsWith("http://") == true || href.StartsWith("https://") == true || href.StartsWith("www") == true) // filter for http
{
mainLinks.Add(href);
}
}
}
return mainLinks;
}
它得到一个URL,返回的URL列表。 相反,我希望该函数将得到一个目录例如c:\ 它会返回一个列表中的所有目录在c:\ 不是子目录只是c:\中的目录,在我的情况下它应该是一个List一个14个目录。
在列表中每个索引中的含义一个目录。
我该怎么办?与目录和DirectoryInfo尝试,但我只是搞砸了。
这与你的其他问题有何根本的不同? http://stackoverflow.com/questions/13058827/how-can-i-get-a-string-and-return-each-time-a-string-from-array – NotMe