Method
LogStream.SafeWriteToFileAsync
SafeWriteToFileAsync(string, string?, CancellationToken) #
Safely writes the specified string to the specified file path asynchronously.
public static Task<bool> SafeWriteToFileAsync(string filePath, string? contents, CancellationToken cancellation = default)Parameters #
filePath string
The path to the file where the string will be written.
contents string?
The string to write 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 write 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.
SafeWriteToFileAsync(string, string?, Encoding, CancellationToken) #
Safely writes the specified string to the specified file path asynchronously.
public static Task<bool> SafeWriteToFileAsync(string filePath, string? contents, Encoding encoding, CancellationToken cancellation = default)Parameters #
filePath string
The path to the file where the string will be written.
contents string?
The string to write to the file. Can be null.
encoding Encoding
The encoding to use when writing the string.
cancellation CancellationToken
The cancellation token to use for the operation. Defaults to None.
Returns #
A task that represents the asynchronous write 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.
SafeWriteToFileAsync(string, string[], CancellationToken) #
Safely writes the specified lines to the specified file path asynchronously.
public static Task<bool> SafeWriteToFileAsync(string filePath, string[] lines, CancellationToken cancellation = default)Parameters #
filePath string
The path to the file where the lines will be written.
lines string[]
The lines to write to the file.
cancellation CancellationToken
The cancellation token to use for the operation. Defaults to None.
Returns #
A task that represents the asynchronous write 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.
SafeWriteToFileAsync(string, string[], Encoding, CancellationToken) #
Safely writes the specified lines to the specified file path asynchronously.
public static Task<bool> SafeWriteToFileAsync(string filePath, string[] lines, Encoding encoding, CancellationToken cancellation = default)Parameters #
filePath string
The path to the file where the lines will be written.
lines string[]
The lines to write to the file.
encoding Encoding
The encoding to use when writing the lines.
cancellation CancellationToken
The cancellation token to use for the operation. Defaults to None.
Returns #
A task that represents the asynchronous write 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.