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
lockType
Type: Microsoft.SharePoint.SPFile.SPLockTypeOne of the enumeration values that describes the type of lock.
lockId
Type: System.StringAn identifier (ID) for the lock.
timeout
Type: System.TimeSpanThe duration of the lock.
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.