Share via


SPFile.Lock method

Creates a lock on the file, preventing other users from modifying it.

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

Syntax

'Declaration
Public Sub Lock ( _
    lockType As SPFile.SPLockType, _
    lockId As String, _
    timeout As TimeSpan _
)
'Usage
Dim instance As SPFile
Dim lockType As SPFile.SPLockType
Dim lockId As String
Dim timeout As TimeSpan

instance.Lock(lockType, lockId, timeout)
public void Lock(
    SPFile.SPLockType lockType,
    string lockId,
    TimeSpan timeout
)

Parameters

Exceptions

Exception Condition
SPFileLockException

lockType is None.

Remarks

You can determine whether the file is already locked by checking the LockType property. If it is None, the file is not locked.

See also

Reference

SPFile class

SPFile members

Microsoft.SharePoint namespace

ReleaseLock(String)

RefreshLock(String, TimeSpan)

LockType