SPList Properties


SPList.RootFolder Property (Microsoft.SharePoint)
Gets the folder that contains all the files that are used in working with the list.

Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
Syntax

Visual Basic (Declaration)
Public ReadOnly Property RootFolder As SPFolder
Visual Basic (Usage)
Dim instance As SPList
Dim value As SPFolder

value = instance.RootFolder
C#
public SPFolder RootFolder { get; }

Property Value

An SPFolder object that represents the root folder.
Remarks

To use the RootFolder property, set the IncludeRootFolder property on the parent SPListCollection object to true.

See Also

Tags :


Community Content

IgorRR
Corresponding SPListItem object

Note, that folder returned by SPList.RootFolder does not have corresponding SPListItem object.

So, SPListObject.RootFolder.Item will return null.

Tags :

johan leino
SPList.RootFolder = internal name of list

Note that you can use the rootfolder to get the internal name of the list, something like this extensionmethod:

public static SPList GetListByInternalName(this SPWeb web, string listInternalName)
{

        var list = (from SPList l in web.Lists
                        where l.RootFolder.Name.Equals(listInternalName, StringComparison.InvariantCulture)
                        select l).FirstOrDefault();
        if (list == null)
        {
            throw new FileNotFoundException(string.Format(
                    "SPList '{0}' not found on web '{1}'", listInternalName, web.Url));
        }
        return list;
}

Thomas Lee
More than RootFolder
RootFolder has much more information than one might think. For example, see how to modify the list rss settings via RootFolder:

http://novatecno.blogspot.com/2009/08/how-modify-splist-rss-programmatically.html


Edge
www.superedge.net

Page view tracker