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.
Пример #1
0
 /// <summary>
 /// Construct a new IniFile.
 /// </summary>
 /// <param name="filePath">path of the IniFile</param>
 public IniFile(string filePath)
 {
     logger   = Logger.GetLogger(GetType());
     textFile = new OptimisticLockedTextFile(filePath);
     Validate();
 }
Пример #2
0
 /// <summary>
 /// Construct a new IniFile.
 /// </summary>
 /// <param name="filePath">path of the IniFile</param>
 public IniFile(string filePath)
 {
     textFile = new OptimisticLockedTextFile(filePath);
     Validate();
 }
 public OptimisticLockedTextFileTester(string fileContents)
 {
     FilePath = Path.GetTempFileName();
     File.WriteAllText(FilePath, fileContents);
     TextFile = new OptimisticLockedTextFile(FilePath);
 }
 public OptimisticLockedTextFileTester(bool createFile = false)
 {
     if (createFile)
     {
         FilePath = Path.GetTempFileName();
     }
     else
     {
         FilePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
     }
     TextFile = new OptimisticLockedTextFile(FilePath);
 }
Пример #5
0
 /// <summary>
 /// Construct a new IniFile.
 /// </summary>
 /// <param name="filePath">path of the IniFile</param>
 public IniFile(string filePath)
 {
     textFile = new OptimisticLockedTextFile(filePath);
     Validate();
 }