SPFolder is one of the SharePoint object and it is a folder in the SharePoint list.To access
the Folder property of that "SPListItem" which will return an SPFolder if the list item is a folder,
Following are some of the properties which SPFolder exposed.
The following WebPart shows how to access the SPFolder object using SharePoint Object Model.
using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Linq;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Data;
namespace SPFolderDemo
{
[ToolboxItemAttribute(false)]
public class SPFolerSample : WebPart
{
StringBuilder spFolderSb = new StringBuilder();
Literal SpLiteral = new Literal();
protected override void CreateChildControls()
{
try
{
SPList list=null
using(SPWeb web=SPContext.Current.Web)
{
list=web.List["SharedDocuments"];
}
SPListItem item=list.item[0];//for testing pointing to index "0"
SPFolder folder=item.Folder;
spFolderSb.Append("Folder Details");
spFolderSb.Append("Folder url:");
spFolderSb.Append(folder.Url);
spFolderSb.Append("Folder contains file");
spFolderSb.Append(folder.Files.Count);
spFolderSb.Append("Is Folder contains sub folder");
spFolderSb.Append(folder.SubFolder.Co);
SpLiterall.Text = spFolderSb.ToString();
this.Controls.Add(SpLiteral);
}
catch (Exception ex)
{
String.Format("Exception. ", ex);
}
}
}