How can i return List of directories instead of url's?
- by user1741587
I have this function :
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;
}
Its getting one url and return list of url's.
Instead i want that the function will get a directory for example c:\
And it will return me a List of all directories in c:\
Not subsirectories just the directories in c:\ in my case it should be a List with a 14 directories.
Meaning in each index in the List a directory.
How can i do it ? Tried with Directory and DirectoryInfo but i just got messed up.