Class AtomicWrite
Provides a temporary path to write to and atomically inserts it at the destination location on disposal (if Commit() was called).
[MustDisposeResource]
public sealed class AtomicWrite
- Inheritance
-
AtomicWrite
- Extension Methods
Examples
using (var atomic = new AtomicWrite(filePath))
{
File.WriteAllBytes(atomic.WritePath, fileData);
atomic.Commit();
}
Constructors
AtomicWrite(string)
Prepares an atomic write operation.
public AtomicWrite(string path)
Parameters
path
stringThe file path of the final destination.
Properties
DestinationPath
The file path of the final destination.
public string DestinationPath { get; }
Property Value
IsCommitted
true
if Commit() has been called.
public bool IsCommitted { get; }
Property Value
WritePath
The temporary file path to write to.
public string WritePath { get; }
Property Value
Methods
Commit()
Allows the new file to be deployed upon Dispose().
public void Commit()
Dispose()
Replaces DestinationPath with the contents of WritePath.
public void Dispose()