Find pages with filename

Please tell me there's a better way to do this than; public PageDataCollection findPagesWithFilename(PageReference pageLink, string filename) { PageDataCollection pages = new PageDataCollection(); foreach(PageData pd in Global.EPDataFactory.GetChildren(pageLink)) { string temp = EPiServer.DataAbstraction.PageType.Load(pd.PageTypeID).FileName; if(temp.Substring(temp.LastIndexOf("/")+1) == filename) pages.Add(pd); pages.Add(findPagesWithFilename(pd.PageLink,filename)); } return pages; }
Aug 21, 2005 10:46
The code is ok for small amounts of pages and non recursive searches. But, you already know the filename you're searching for, why not map that to the pagetype by iterating through the PageType collection and look for it. When you know the pagetype, you can do a property search (FindPagesByCriteria(...)) with the PageTypeID as a search parameter. This should give you better performance if you're searching through a lot of pages. /Steve
Aug 22, 2005 7:18
Ahhh. I need a vacation. Thank you!
Aug 22, 2005 14:02
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.