# InteractionFile Methods

- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Type: [InteractionFile](/reference/api/csharp/aspire.hosting/interactionfile.md)
- Kind: `Methods`
- Members: `2`

Represents a file selected by the user for an [InputType.File](/reference/api/csharp/aspire.hosting/inputtype/fields.md) input.

<a id="openread"></a>

## OpenRead

- Name: `OpenRead`
- Returns: `Stream`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/b5f143315ffb6968ea939a9978797a5b20e4c688/src/Aspire.Hosting/IInteractionService.cs#L475)

Opens a read-only stream for the file content.

```csharp
public sealed class InteractionFile
{
    public Stream OpenRead()
    {
        // ...
    }
}
```

## Returns

`Stream` -- A `IO.Stream` for reading the file.

<a id="readallbytesasync"></a>
<a id="readallbytesasync-cancellationtoken"></a>

## ReadAllBytesAsync(CancellationToken)

- Name: `ReadAllBytesAsync(CancellationToken)`
- Returns: `Task<byte[]>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/b5f143315ffb6968ea939a9978797a5b20e4c688/src/Aspire.Hosting/IInteractionService.cs#L482)

Reads all bytes of the file asynchronously.

```csharp
public sealed class InteractionFile
{
    public Task<byte[]> ReadAllBytesAsync(
        CancellationToken cancellationToken = default(CancellationToken))
    {
        // ...
    }
}
```

## Parameters

- `cancellationToken` (`CancellationToken`) `optional`
  A token to monitor for cancellation requests.

## Returns

`Task<byte[]>` -- A byte array containing the file content.
