Class OptimisticLockedTextFile
Provides line-based read/write access to a file. The file can be read into memory, changed, then written back to disk. When the file is persisted back to disk, an optimistic concurrency check is performed to make sure the file hasn't changed since it was originally read.
This class is not threadsafe.
public class OptimisticLockedTextFile
- Inheritance
-
OptimisticLockedTextFile
- Inherited Members
Constructors
OptimisticLockedTextFile(string)
Construct a new OptimisticLockedTextFile.
public OptimisticLockedTextFile(string filePath)
Parameters
filePath
stringpath of the file
Properties
FilePath
path of the file
public string FilePath { get; }
Property Value
Lines
Read/write access to the lines that make up the file. Any changes to this List are persisted back to disk when Persist() is called.
NOTE: The lines have the original line endings on them to preserve the original text as much as possible.
public List<string> Lines { get; }
Property Value
Methods
Persist()
Persist changes to disk after an optimistic concurrency check is completed.
public void Persist()
ToString()
public override string ToString()