Method
LogStream.SafeAppendToFileAsync
SafeAppendToFileAsync(string, string?, CancellationToken) #
Safely appends the specified string to the specified file path asynchronously.
public static Task<bool> SafeAppendToFileAsync(string filePath, string? text, CancellationToken cancellation = default)Parameters #
filePath string
The path to the file where the string will be appended.
text string?
The string to append to the file. Can be null.
cancellation CancellationToken
The cancellation token to use for the operation. Defaults to None.
Returns #
A task that represents the asynchronous append operation. The task returns true if the operation was successful, otherwise false.
Remarks #
Calls to these file helper methods for the same normalized full path are serialized within the current process. Synchronous and asynchronous overloads share the same per-file lock, while calls for different files can run concurrently. Access is not coordinated across processes.
SafeAppendToFileAsync(string, string?, Encoding, CancellationToken) #
Safely appends the specified string to the specified file path asynchronously.
public static Task<bool> SafeAppendToFileAsync(string filePath, string? text, Encoding encoding, CancellationToken cancellation = default)Parameters #
filePath string
The path to the file where the string will be appended.
text string?
The string to append to the file. Can be null.
encoding Encoding
The encoding to use when appending the string.
cancellation CancellationToken
The cancellation token to use for the operation. Defaults to None.
Returns #
A task that represents the asynchronous append operation. The task returns true if the operation was successful, otherwise false.
Remarks #
Calls to these file helper methods for the same normalized full path are serialized within the current process. Synchronous and asynchronous overloads share the same per-file lock, while calls for different files can run concurrently. Access is not coordinated across processes.
SafeAppendToFileAsync(string, string[], CancellationToken) #
Safely appends the specified lines to the specified file path asynchronously.
public static Task<bool> SafeAppendToFileAsync(string filePath, string[] lines, CancellationToken cancellation = default)Parameters #
filePath string
The path to the file where the lines will be appended.
lines string[]
The lines to append to the file.
cancellation CancellationToken
The cancellation token to use for the operation. Defaults to None.
Returns #
A task that represents the asynchronous append operation. The task returns true if the operation was successful, otherwise false.
Remarks #
Calls to these file helper methods for the same normalized full path are serialized within the current process. Synchronous and asynchronous overloads share the same per-file lock, while calls for different files can run concurrently. Access is not coordinated across processes.
SafeAppendToFileAsync(string, string[], Encoding, CancellationToken) #
Safely appends the specified lines to the specified file path asynchronously.
public static Task<bool> SafeAppendToFileAsync(string filePath, string[] lines, Encoding encoding, CancellationToken cancellation = default)Parameters #
filePath string
The path to the file where the lines will be appended.
lines string[]
The lines to append to the file.
encoding Encoding
The encoding to use when appending the lines.
cancellation CancellationToken
The cancellation token to use for the operation. Defaults to None.
Returns #
A task that represents the asynchronous append operation. The task returns true if the operation was successful, otherwise false.
Remarks #
Calls to these file helper methods for the same normalized full path are serialized within the current process. Synchronous and asynchronous overloads share the same per-file lock, while calls for different files can run concurrently. Access is not coordinated across processes.