SPFileVersion.Properties property
Gets metadata for the file version.
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'Declaration
Public ReadOnly Property Properties As Hashtable
Get
'Usage
Dim instance As SPFileVersion
Dim value As Hashtable
value = instance.Properties
public Hashtable Properties { get; }
Property value
Type: System.Collections.Hashtable
A System.Collections.Hashtable object that contains the metadata.
Examples
The following code example iterates through the collection of versions for a specified file and displays the properties and values for each version.
This example requires using directives (Imports in Visual Basic) for the Microsoft.SharePoint and Microsoft.SharePoint.Utilities namespaces.
Dim siteCollection As SPSite = SPControl.GetContextSite(Context)
Dim site As SPWeb = siteCollection.AllWebs("Site_Name")
Dim files As SPFileCollection = site.Folders("Shared Documents").Files
Dim fileVersions As SPFileVersionCollection =
files("File_Name").Versions
Dim fileVersion As SPFileVersion
For Each fileVersion In fileVersions
Dim hash As System.Collections.Hashtable = fileVersion.Properties
Dim keys As System.Collections.ICollection = hash.Keys
Dim key As Object
For Each key In keys
Response.Write(SPEncode.HtmlEncode(key.ToString()) & " :: " &
SPEncode.HtmlEncode(hash(key.ToString()).ToString()) &
"<BR>")
Next key
Next fileVersion
SPSite oSiteCollection = SPContext.Current.Site;
using (SPWeb oWebsite = oSiteCollection.AllWebs["Site_Name"])
{
SPFileCollection collFiles = oWebsite.Folders["Shared Documents"].Files;
SPFileVersionCollection collFileVersions = collFiles["File_Name"].Versions;
foreach (SPFileVersion oFileVersion in collFileVersions)
{
System.Collections.Hashtable oHash = oFileVersion.Properties;
System.Collections.ICollection collKeys = oHash.Keys;
foreach (object oKey in collKeys)
{
Response.Write(SPEncode.HtmlEncode(oKey.ToString()) +
" :: " + SPEncode.HtmlEncode(oHash[oKey.ToString()].ToString()) + "<BR>");
}
}
}
The previous example displays metadata such as the following:
vti_sourcecontrolcookie :: fp_internal
vti_timelastmodified :: 5/6/2003 8:42:10 PM
vti_sourcecontrolversion :: V2
vti_cachedcustomprops :: vti_title
vti_hasdefaultcontent :: true
vti_cachedtitle :: File_Title
vti_title :: File_Title
vti_modifiedby :: User_Name
vti_oldversion :: 1
vti_filesize :: 19968
vti_author :: User_Name
Note
Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects.