Table of Contents

Class FileAsset

Namespace
VpnHood.Net.Toolkit.Assets
Assembly
VpnHood.Net.Toolkit.dll

Represents a file as an asset, for a caller that was given a path rather than a provider: a test, a tool, or an app that already knows where the file lies.

public class FileAsset : IAsset
Inheritance
FileAsset
Implements
Inherited Members

Remarks

It keeps every asset's contract, so what takes it cannot tell: a missing file throws AssetNotFoundException, not a plain FileNotFoundException. Absence is what Exists(string) tells, so a file it cannot see, such as one without read permission, counts as absent.

Constructors

FileAsset(string)

Represents a file as an asset, for a caller that was given a path rather than a provider: a test, a tool, or an app that already knows where the file lies.

public FileAsset(string filePath)

Parameters

filePath string

The file's path.

Remarks

It keeps every asset's contract, so what takes it cannot tell: a missing file throws AssetNotFoundException, not a plain FileNotFoundException. Absence is what Exists(string) tells, so a file it cannot see, such as one without read permission, counts as absent.

Methods

OpenReadAsync(CancellationToken)

Opens the asset.

public Task<Stream> OpenReadAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<Stream>

A task whose result is a new stream, which the caller owns and disposes; read it forward.

Exceptions

AssetNotFoundException

There is no such asset.

ToString()

Returns the file's path.

public override string ToString()

Returns

string

The path.