Friday, May 06, 2011

Listing all Folder in SharePoint 2010

To list all the "Folders" in a site or web in SharePoint 2010
SPSite site = SPContext.Current.Site;
            SPFolderCollection cols =  site.OpenWeb().Folders;
            foreach (SPFolder folder in cols)
            {
                ListBox1.Items.Add(folder.Name.ToString());
            }