Table of Contents

Class File

Namespace
CarinaStudio.IO
Assembly
CarinaStudio.AppBase.Core.dll

Provide utility methods for files.

public static class File
Inheritance
File
Inherited Members

Methods

ExistsAsync(string?, CancellationToken)

Check whether the given file exists or not asynchronously.

public static Task<bool> ExistsAsync(string? path, CancellationToken cancellationToken = default)

Parameters

path string

Path to the file.

cancellationToken CancellationToken

Cancellation.

Returns

Task<bool>

Task of checking existence of file.

TryOpen(string, FileMode, FileAccess, int, out FileStream?)

Try opening file with given timeout.

public static bool TryOpen(string fileName, FileMode mode, FileAccess access, int timeoutMillis, out FileStream? stream)

Parameters

fileName string

File name.

mode FileMode

Mode to open file.

access FileAccess

Desired access.

timeoutMillis int

Timeout in milliseconds.

stream FileStream

Opened stream.

Returns

bool

True if file opened successfully in given timeout.

TryOpenRead(string, int, out FileStream?)

Try opening file for reading with given timeout.

public static bool TryOpenRead(string fileName, int timeoutMillis, out FileStream? stream)

Parameters

fileName string

File name.

timeoutMillis int

Timeout in milliseconds.

stream FileStream

Opened stream.

Returns

bool

True if file opened successfully in given timeout.

TryOpenReadWrite(string, int, out FileStream?)

Try opening file for reading and writing with given timeout.

public static bool TryOpenReadWrite(string fileName, int timeoutMillis, out FileStream? stream)

Parameters

fileName string

File name.

timeoutMillis int

Timeout in milliseconds.

stream FileStream

Opened stream.

Returns

bool

True if file opened successfully in given timeout.

TryOpenWrite(string, int, out FileStream?)

Try opening file for writing with given timeout.

public static bool TryOpenWrite(string fileName, int timeoutMillis, out FileStream? stream)

Parameters

fileName string

File name.

timeoutMillis int

Timeout in milliseconds.

stream FileStream

Opened stream.

Returns

bool

True if file opened successfully in given timeout.