VFile.AppendAllLinesAsync Method
Namespace: Rebex.IO
Assembly: Rebex.FileSystem.dll (version 7.0.9448)
AppendAllLinesAsync(String, IEnumerable<String>, CancellationToken)
Method appends contents
to a file identified by the path.
Declaration
public static Task AppendAllLinesAsync(string path, IEnumerable<string> contents, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| String | path | The path of the file. |
| IEnumerable<String> | contents | The lines to be appended to the file. |
| CancellationToken | cancellationToken | The cancellation token. See remarks for details. |
Returns
| Type | Description |
|---|---|
| Task | A Task that represents the operation. See remarks for details. |
Remarks
- Method creates the file if it does not exist, opens the file, writes the content and closes the file.
-
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 completed Task.
The
cancellationTokenis 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 AppendAllLines(String, IEnumerable<String>) method.
AppendAllLinesAsync(String, IEnumerable<String>, Encoding, CancellationToken)
Method appends contents to a file identified
by the path and using a encoding.
Declaration
public static Task AppendAllLinesAsync(string path, IEnumerable<string> contents, Encoding encoding, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| String | path | The path of the file. |
| IEnumerable<String> | contents | The lines to be appended to the file. |
| Encoding | encoding | The character encoding. |
| CancellationToken | cancellationToken | The cancellation token. See remarks for details. |
Returns
| Type | Description |
|---|---|
| Task | A Task that represents the operation. See remarks for details. |
Remarks
- Method creates the file if it does not exist, opens the file, writes the content and closes the file.
-
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 completed Task.
The
cancellationTokenis 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.AppendAllLinesAsync(System.String,System.Collections.Generic.IEnumerable{System.String},System.Threading.CancellationToken) method.