Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
SDK Documentation
SPList Class
SPList Properties
 RootFolder Property

  Switch on low bandwidth view
Community Content
In this section
Statistics Annotations (0)
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)
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.

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

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Corresponding SPListItem object      IgorRR   |   Edit   |   Show History

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

So, SPListObject.RootFolder.Item will return null.

Tags What's this?: Add a tag
Flag as ContentBug
SPList.RootFolder = internal name of list      JohanLe   |   Edit   |   Show History

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;
}
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker