Interface IFileWriterService
Interface for atomic file writing operations.
Ensures that file writes are completed fully or not at all, preventing data corruption.
Inherited Members
Namespace: Serenity.FilePersistence.Application.Interfaces
Assembly: Serenity.Global.Application.dll
Syntax
public interface IFileWriterService : IService, IFoundationSettings
Methods
Write(string, ReadOnlySpan<byte>)
Writes data to a file.
If the write operation fails, the original file remains unchanged.
Declaration
void Write(string path, ReadOnlySpan<byte> data)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The file path where data should be written. |
| ReadOnlySpan<byte> | data | The data to write. |
WriteAsync(string, ReadOnlyMemory<byte>, CancellationToken)
Asynchronously writes data to a file.
If the write operation fails, the original file remains unchanged.
Declaration
Task WriteAsync(string path, ReadOnlyMemory<byte> data, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The file path where data should be written. |
| ReadOnlyMemory<byte> | data | The data to write. |
| CancellationToken | cancellationToken | Cancellation token for async operation |
Returns
| Type | Description |
|---|---|
| Task | Task representing the asynchronous operation. |