VFile.WriteAllTextAsync Method
Namespace: Rebex.IO
Assembly: Rebex.FileSystem.dll (version 7.0.9147)
WriteAllTextAsync(String, String, CancellationToken)
Method writes contents
to a file identified by the path
.
Declaration
public static Task WriteAllTextAsync(string path, string contents, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
String | path | The path of the file. |
String | contents | The string to write to the file. |
Cancellation |
cancellationToken | The cancellation token. See remarks for details. |
Returns
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
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. method.File System. IO. VFile. Write All Text(System. String,System. String)
WriteAllTextAsync(String, String, Encoding, CancellationToken)
Method writes contents
to a file identified by the path
and using the encoding
.
Declaration
public static Task WriteAllTextAsync(string path, string contents, Encoding encoding, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
String | path | The path of the file. |
String | contents | The string to write to the file. |
Encoding | encoding | The character encoding. |
Cancellation |
cancellationToken | The cancellation token. See remarks for details. |
Returns
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
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. method.File System. IO. VFile. Write All Text(System. String,System. String,System. Text. Encoding)