VFile.ReadAllLinesAsync Method
Namespace: Rebex.IO
Assembly: Rebex.FileSystem.dll (version 7.0.9119)
ReadAllLinesAsync(String, CancellationToken)
Method returns a string array that contains all lines from a text file identified by the path
.
Declaration
public static Task<string[]> ReadAllLinesAsync(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 the string array that contains all lines form a text file identified by the |
Remarks
- All lines are 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 array 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.ReadAllLines(System.String) method.
ReadAllLinesAsync(String, Encoding, CancellationToken)
Method returns a string array that contains all lines from a text file identified by the path
.
Declaration
public static Task<string[]> ReadAllLinesAsync(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 the string array that contains all lines form a text file identified by the |
Remarks
- All lines are 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 array 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.ReadAllLines(System.String) method.