SP.Folder object
Represents a folder on a SharePoint Web site.
Applies to: apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013
var object = new SP.Folder()
Members
The Folder object has the following members.
Constructor
The Folder object has the following constructor.
Constructor |
Description |
---|---|
Initializes a new instance of the SP.Folder object. |
Methods
The Folder object has the following methods.
Method |
Description |
---|---|
Deletes the list folder. |
|
Moves the list folder to the Recycle Bin and returns the identifier of the new Recycle Bin item. |
|
Updates the list folder with changes that have been made to the list folder properties. |
Properties
The Folder object has the following properties.
Property |
Description |
---|---|
Specifies the sequence in which content types are displayed. |
|
Gets the collection of all files contained in the list folder. |
|
Gets the collection of list folders contained in the list folder. |
|
Gets a value that specifies the count of items in the list folder. |
|
Specifies the list item field (2) values for the list item corresponding to the file. |
|
Gets the name of the folder. |
|
Gets the parent list folder of the folder. |
|
Gets the collection of all files contained in the folder. |
|
Gets the server-relative URL of the list folder. |
|
Gets or sets a value that specifies the content type order. |
|
Gets or sets a value that specifies folder-relative URL for the list folder welcome page. |
Remarks
The UniqueContentTypeOrder property is not included in the default scalar property set for this type.
Example
The following example creates an input button on an application page that lists the folders on the current Web site.
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<script type="text/ecmascript" language="ecmascript">
var folderCollection;
function runCode() {
var clientContext = new SP.ClientContext.get_current();
if (clientContext != undefined && clientContext != null) {
this.web = clientContext.get_web();
this.folderCollection = web.get_folders();
clientContext.load(this.folderCollection);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
}
function onQuerySucceeded(sender, args) {
var folderInfo = 'The current site contains the following folders:\n\n';
var folderEnumerator = this.folderCollection.getEnumerator();
while (folderEnumerator.moveNext()) {
var folderItem = folderEnumerator.get_current();
folderInfo += folderItem.get_name() + '\n';
}
alert(folderInfo);
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
</script>
<input id="Button1" type="button" value="Run Code" onclick="runCode()" />
</asp:Content>
REST resource endpoint
See Folder resource for more information.
Endpoint URI structure
http://<sitecollection>/<site>/_api/web/folders/getbyurl(folderrelativeurl)
HTTP requests
This resource supports the following HTTP commands:
DELETE syntax
DELETE http://<sitecollection>/<site>/_api/web/folders/getbyurl(folderrelativeurl)
MERGE syntax
MERGE http://<sitecollection>/<site>/_api/web/folders/getbyurl(folderrelativeurl)
POST syntax
POST http://<sitecollection>/<site>/_api/web/folders/getbyurl(folderrelativeurl)
PUT syntax
PUT http://<sitecollection>/<site>/_api/web/folders/getbyurl(folderrelativeurl)