Table of contents
TOC
Collapse the table of content
Expand the table of content

FileFolderExtensions.EnsureFolder Method

SharePoint Dev Documents|Last Updated: 5/22/2017
|
1 Contributor

Checks if the folder exists at the top level of the web site, and if it does not exist creates it. Note it is more common to create folders within an existing Folder, such as the RootFolder of a List.

Namespace:Microsoft.SharePoint.Client
Assembly: OfficeDevPnP.Core.dll

Syntax

public static Folder EnsureFolder(this Web web, String folderName, params Expression<Func<Folder, Object>>[] expressions)

Parameters

web

  Type: Microsoft.SharePoint.Client.Web
  Web to check for the named folder

folderName

  Type: System.String
  Folder name to retrieve or create

expressions

  Type: System.Linq.Expressions.Expression<System.Func<Microsoft.SharePoint.Client.Folder, System.Object>>[]
  List of lambda expressions of properties to load when retrieving the object

Return Value

Type: Folder
The existing or newly created folder

Remarks

Note that this only checks one level of folder (the Folders collection) and cannot accept a name with path characters.

See also

© 2018 Microsoft