SPFileVersionCollection.RestoreByID method (Int32, String)

Restores the file version object that has the specified version ID to the collection with the specified lock ID.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'Declaration
Public Sub RestoreByID ( _
    vid As Integer, _
    bypassSharedLockId As String _
)
'Usage
Dim instance As SPFileVersionCollection
Dim vid As Integer
Dim bypassSharedLockId As String

instance.RestoreByID(vid, bypassSharedLockId)
public void RestoreByID(
    int vid,
    string bypassSharedLockId
)

Parameters

  • bypassSharedLockId
    Type: System.String

    The lock ID on the file.

Remarks

If versioning is enabled for the document library and the file is not checked out, the current file becomes the most recent version when a version is restored.

Using the RestoreByID method is the same as using a combination of the OpenBinary method of the SPFileVersion class and the SaveBinary method of the SPFile class, as in myVersion.File.SaveBinary(myVersions[5].OpenBinary). However, the RestoreByID method is more efficient.

If the file has a shared lock, the lock ID must be a match for the restore operation.

See also

Reference

SPFileVersionCollection class

SPFileVersionCollection members

RestoreByID overload

Microsoft.SharePoint namespace