/// <summary> /// Lock part of a file. /// </summary> /// <param name="file">The file to lock.</param> /// <param name="offset">The offset into the file to lock</param> /// <param name="size">The number of bytes to lock</param> /// <param name="fail_immediately">True to fail immediately if the lock can't be taken</param> /// <param name="exclusive">True to do an exclusive lock</param> /// <param name="throw_on_error">True to throw on error.</param> /// <returns>The NT status code.</returns> public static NtResult <NtFileScopedLock> Create(NtFile file, long offset, long size, bool fail_immediately, bool exclusive, bool throw_on_error) { return(file.Lock(offset, size, fail_immediately, exclusive, false).CreateResult(throw_on_error, () => new NtFileScopedLock(file, offset, size))); }