Compartilhar 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)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

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