private List <shootList> recGetAllShoots(string url, int count) { if (count == 5) { string[] splitUrl = Regex.Split(url, "Shoots"); List <shootList> Shoots = new List <shootList>(); foreach (var s in new DirectoryInfo(url).GetDirectories()) { string newUrl = "/Shoots" + splitUrl[1] + "/" + s.Name; if (Directory.EnumerateFileSystemEntries(s.FullName, "index.html").Any()) { newUrl = newUrl + "/index.html"; } else { newUrl = newUrl + "/default.htm"; } shootList sL = new shootList(); sL.href = newUrl; sL.title = s.Name; Shoots.Add(sL); } return(Shoots); } else { List <shootList> Shoots = new List <shootList>(); foreach (var s in new DirectoryInfo(url).GetDirectories()) { Shoots.AddRange(recGetAllShoots(url + "\\" + s.Name, count + 1)); } return(Shoots); } }
public List <shootList> getAllShoots(string url) { List <shootList> allShoots = new List <shootList>(); string[] splitUrl = Regex.Split(url, "Shoots"); string[] urlWords = urlWords = splitUrl[1].Split('\\');; int wordsCount = urlWords.Count(); if (wordsCount == 5) { foreach (var s in new DirectoryInfo(url).GetDirectories()) { string newUrl = "/Shoots" + splitUrl[1] + "/" + s.Name; if (Directory.EnumerateFileSystemEntries(s.FullName, "index.html").Any()) { newUrl = newUrl + "/index.html"; } else { newUrl = newUrl + "/default.htm"; } shootList sL = new shootList(); sL.href = newUrl; sL.title = s.Name; allShoots.Add(sL); } } else { foreach (var s in new DirectoryInfo(url).GetDirectories()) { allShoots.AddRange(recGetAllShoots(url + "\\" + s.Name, wordsCount + 1)); } } return(allShoots); }