Possible Duplicate:
How can i get a string and return each time a string from array?
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.
The static method
Directory.EnumerateDirectories(string path)returnsSource: MSDN
You can use the methods in the class
Pathto get the name of a directory, e.g.Path.GetDirectoryName(string path). Read the documentation carefully at MSDN.