SPList.SaveAsTemplate Method
Saves the list as a template in the list template gallery and includes the option of saving with or without the data that is contained in the current list.
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
public void SaveAsTemplate( string strFileName, string strName, string strDescription, bool bSaveData )
Parameters
- strFileName
- Type: System.String
The file name for the list template with an .stp extension.
- strName
- Type: System.String
The title for the list template.
- strDescription
- Type: System.String
The description for the list template.
- bSaveData
- Type: System.Boolean
true to save the data of the original list along with the list template; otherwise, false.
| Exception | Condition |
|---|---|
| Exception |
Cannot save the list as a template. |
The following code example saves a list, including its user data, on a specified site as a template.
This example requires using directives (Imports in Visual Basic) for the Microsoft.SharePoint and Microsoft.SharePoint.Utilities namespaces.