locked
getting all aspx pages RRS feed

  • Question

  • I need to have a regular expression to get all aspx pages from a site, now these pages can be directly at root level, in site pages library or publishing pages library.

    E.g.

    1.    http://Demo/sites/<siteName>/*.aspx

    2.    http://Demo/*.aspx

    now how do i iterate through all site pages and filter out .aspx pages?


    Ujwal Seli
    Tuesday, January 17, 2012 7:54 AM

Answers

  • please try this

     using (SPSite site = new SPSite("Url"))
                {
                    SPWeb web = site.RootWeb;
                    SPFileCollection fileColl = web.Files;
                    foreach (SPFile file in fileColl)
                    {
                        if (file.Name.EndsWith(".aspx"))
                        {
                            Console.WriteLine(file.Name);
                        }
                    }
    }

     


    Manoj Gangwar | Sharepoint 2010 MCPD | Sharepoint 2010 MCTS
    • Marked as answer by Ujwal Seli Tuesday, January 17, 2012 9:00 AM
    Tuesday, January 17, 2012 8:52 AM