Export (0) Print
Expand All

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

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

Parameters

lockType
Type: Microsoft.SharePoint.SPFile.SPLockType

One of the enumeration values that describes the type of lock.

lockId
Type: System.String

An identifier (ID) for the lock.

timeout
Type: System.TimeSpan

The duration of the lock.

ExceptionCondition
SPFileLockException

lockType is None.

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

Show:
© 2014 Microsoft