# HaspFile.Read Method

Namespace: Aladdin.Hasp

## Description

Retrieves content from a memory file in a Sentinel protection key.

## Syntax

    HaspStatus Read ( ref Boolean value)

## Parameters

`value` | Reference to the Boolean object that receives the data.

## Return Values

A HaspStatus status code.

## Usage Notes

Use the Hasp.FileSize method to determine the size of the file that you want to read.

Use the HaspFile constructor to specify the file to read.

To start the read operation from an offset other than zero, set the property HaspFile.FilePos before you call the HaspFile.Read method.

NOTE To defeat a protection key emulator attempting to bypass software protection, you can check periodically that the protection key is available and that a session for the key exists. This should not be done using GetSessionInfo (this method does not detect a remote broken session). Instead, use one of the following methods: Encrypt, Decrypt, Read, Write. These methods will return HASP_BROKEN_SESSION if a session for the protection key does not exist.

## Overloaded Methods

The following overloaded methods are provided. They differ from the method above only in the argument type that they accept.

    HaspStatus HaspFile.Read ( ref Byte   value )HaspStatus HaspFile.Read ( ref Char   value )HaspStatus HaspFile.Read ( ref Double value )HaspStatus HaspFile.Read ( ref Int16  value )HaspStatus HaspFile.Read ( ref Int32  value )HaspStatus HaspFile.Read ( ref Int64  value )HaspStatus HaspFile.Read ( ref Single value )HaspStatus HaspFile.Read ( ref String value )HaspStatus HaspFile.Read ( ref UInt16 value )HaspStatus HaspFile.Read ( ref UInt32 value )HaspStatus HaspFile.Read ( ref UInt64 value )

The following additional overloaded method is provided:

    public HaspStatus Read(Byte[] buffer,
                           Int32  index,
                           Int32  count)

Parameter | Description
--- | ---
`buffer` | Byte array that receives the data.
`index` | Index in the byte array at which the data is stored. Do not confuse the index with the offset in the file from where the read operation starts.
`count` | Size of the data to be read from the file.

## Related Topics

GetSize Method

Write Method