SPFolder.Properties Property
Gets a hash table that contains metadata for the folder.
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
The following code example iterates through the collection of folders in the current Web site and displays the properties and values for each folder.
This example requires using directives (Imports in Visual Basic) for the Microsoft.SharePoint and Microsoft.SharePoint.Utilities namespaces.
SPWeb oWebsite = SPContext.Current.Web; SPFolderCollection collFolders = oWebsite.Folders; foreach (SPFolder oFolder in collFolders) { System.Collections.Hashtable oHashtable = oFolder.Properties; System.Collections.ICollection collKeys = oHashtable.Keys; foreach (object oKey in collKeys) { Response.Write(SPEncode.HtmlEncode(oKey.ToString()) + " :: " + SPEncode.HtmlEncode(hashtable[oKey.ToString()]) + "<BR>"); } }
The previous example displays metadata such as the following:
vti_dirlateststamp :: 8/30/2006 1:06:19 AM
vti_etag :: "{101141FF-9E99-4404-AE4D-561B981472E4},0"
vti_isexecutable :: false
vti_candeleteversion :: true
vti_docstoretype :: 1
vti_timecreated :: 8/21/2006 1:28:31 AM
vti_isbrowsable :: true
vti_hassubdirs :: true
vti_listname :: {B6C3C6F9-A256-4FA4-B6A2-97549D48E530}
vti_replid :: rid:{101141FF-9E99-4404-AE4D-561B981472E4}
vti_listenableversioning :: false
vti_listenableminorversions :: false
vti_listbasetype :: 1
vti_level :: 1
vti_rtag :: rt:101141FF-9E99-4404-AE4D-561B981472E4@00000000000
vti_timelastmodified :: 8/21/2006 1:28:41 AM
vti_listservertemplate :: 101
vti_listrequirecheckout :: false
vti_listenablemoderation :: false
vti_listtitle :: TestDocLib2
vti_isscriptable :: false
Properties can be set
list.RootFolder.Properties["122"] = "123";
string temp = list.RootFolder.Properties["122"] as string;
Use it for updating meta-data for your folder: it's faster than using item.update()
Instead of using:
SPFolder ArchiveFolder = MonthFolder.SubFolders.Add("Folder 1");
ArchiveFolder.UniqueContentTypeOrder = contentTypes;
ArchiveFolder.Update();
//Process all about the folder item
ArchiveFolder.Item["Title"] = this._PONumber;
ArchiveFolder.Item["PONumber"] = this._PONumber;
ArchiveFolder.Item["ContentTypeId"] = ePOFolder.Id.ToString(); // Fix the content type for the folder
ArchiveFolder.Item.Update();
use:
ArchiveFolder = MonthFolder.SubFolders.Add("Folder 1");
ArchiveFolder.UniqueContentTypeOrder = contentTypes;
//Process all about the folder item
ArchiveFolder.Properties.Add("Title", this._PONumber);
ArchiveFolder.Properties.Add("PONumber", this._PONumber);
ArchiveFolder.Properties.Add("ContentTypeId", ePOFolder.Id.ToString()); // Fix the content type for the folder
ArchiveFolder.Update();
I have written an article on my blog http://apichot.blogspot.com/2008/05/sharepoint-item-update-is-nightmare.html
- 5/8/2008
- Antoine Pichot