System.IO.FileStream.Lock Method

Prevents other processes from reading from or writing to the System.IO.FileStream.

Syntax

public virtual void Lock (long position, long length)

Parameters

position
The beginning of the range to lock. The value of this parameter must be equal to or greater than zero (0).
length
The range to be locked.

Remarks

Locking a range of a file stream gives the threads of the locking process exclusive access to that range of the file stream.

For a list of common file and directory operations, see Common I/O Tasks.

Requirements

Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0