Rebex
Products Downloads Buy Support Contact
Show / Hide Table of Contents

VFile.ReadAllTextAsync Method

Namespace: Rebex.IO
Assembly: Rebex.FileSystem.dll (version 7.0.9147)

ReadAllTextAsync(String, CancellationToken)

Method returns a String that contains text content of a file identified by the path.

Declaration
public static Task<string> ReadAllTextAsync(string path, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
String path

The path of the file.

CancellationToken cancellationToken

The cancellation token. See remarks for details.

Returns
Type Description
Task<String>

A Task<TResult>, which wraps text content of a file identified by the path.

Remarks
  • Content of the file is read using the UTF-8 encoding.
  • Rebex virtual file systems are synchronous. This method is provided only for compatibility with the File API on modern platforms. Despite the async suffix this method runs synchronously and returns a string wrapped in the instance of the Task<string> class. The cancellationToken is not used. If the need to offload the operation to the background thread arise, consider using the .NET Task.Run (or TaskFactory.StartNew on older platforms) API with the synchronous Rebex.IO.FileSystem.IO.VFile.ReadAllText(System.String) method.

ReadAllTextAsync(String, Encoding, CancellationToken)

Method returns a String that contains text content of a file identified by the path. Content of the file is read using the provided encoding.

Declaration
public static Task<string> ReadAllTextAsync(string path, Encoding encoding, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
String path

The path of the file.

Encoding encoding

The character encoding.

CancellationToken cancellationToken

The cancellation token. See remarks for details.

Returns
Type Description
Task<String>

A Task<TResult>, which wraps text content of a file identified by the path.

Remarks

Rebex virtual file systems are synchronous. This method is provided only for compatibility with the File API on modern platforms. Despite the async suffix this method runs synchronously and returns a string wrapped in the instance of the Task<string> class. The cancellationToken is not used. If the need to offload the operation to the background thread arise, consider using the .NET Task.Run (or TaskFactory.StartNew on older platforms) API with the synchronous Rebex.IO.FileSystem.IO.VFile.ReadAllText(System.String,System.Text.Encoding) method.

In This Article
  • ReadAllTextAsync(String, CancellationToken)
  • ReadAllTextAsync(String, Encoding, CancellationToken)
© REBEX ČR s.r.o. Back to top
Privacy policy
Manage cookies