Compartilhar via


SPFileVersion Class

The SPFileVersion class represents a version of an SPFile object.

System.Object

   Microsoft.SharePoint.SPFileVersion

Public Methods

The following table shows the public methods of the SPFileVersion class and a brief description of each.

Name Description
OpenBinary Returns a byte array that contains the file version.

Public Properties

The following table shows the public properties of the SPFileVersion class, the data type of each property, and a brief description of each.

Name Data Type Description
CheckInComment String Gets the latest check-in comment for the file before it became a version.
Created System.DateTime Gets the creation date and time for the file version.
CreatedBy Microsoft.SharePoint.SPUser Gets the SPUser object that represents the creator of the file version.
File Microsoft.SharePoint.SPFile Gets the parent file object for the version.
ID Int32 Gets the internal identifier for the file version.
Properties System.Collections.Hashtable Gets metadata for the file version.
Size Int32 Gets the size of the file version in bytes.
Url String Gets the relative URL of the file version based on the URL for the site or subsite.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread safe.

Remarks

When a file becomes a version, its properties are maintained with the version. This includes the check-in comment and other information for the file.

Use the Versions property of the SPFile class to return an SPFileVersionCollection object that represents the collection of versions for a file. Use an indexer to return a single version from the collection. For example, if the collection is assigned to a variable named myVersions, use myVersions[index] in C#, or myVersions(index) in Visual Basic .NET, where index is the index number of the version in the collection. Otherwise, use the GetVersionFromId method to return a single version from the collection.

If file versioning is enabled for a document library, calling the CheckIn method of the SPFile class after using the CheckOut method creates a version of the file. Likewise, calling the SaveBinary method of the SPFile class also creates a version.

Requirements

Namespace: Microsoft.SharePoint

Platforms: Microsoft Windows Server 2003

Assembly: Windows SharePoint Services (in Microsoft.SharePoint.dll)

Security: Code Access Security