[Test]public void ContentAddedDoesNotPersistsAfterRollbackTest(){ string fileName = "file3.txt"; string originalContents = "First contents"; using (TransactionScope scope = new TransactionScope()) { string newContents = "Hello transacted NTFS."; using (StreamWriter sw = TxFileStream.CreateWriter(fileName)) { sw.Write(newContents); } using (StreamReader sr = TxFileStream.CreateReader(fileName)) { string text = sr.ReadToEnd(); Assert.That(text, Is.EqualTo(newContents)); } // no call to scope.Complete() forces a rollback. } Assert.That(File.Exists(fileName)); Assert.That(File.ReadAllText(fileName), Is.EqualTo(originalContents));}
Kennedy.TxFiles.zip (36 KB)Of course, my library comes with comprehensive unit tests. Look here first to figure out how out use the library.
Note: I fixed a bug in creating transactional StreamWriter's in append mode. Previously they partially overwrote the existing content.
Remember Me
a@href@title, b, blockquote@cite, em, i, strike, strong, sub, sup, u
Page rendered at Friday, July 04, 2008 2:55:17 PM (Eastern Standard Time, UTC-05:00)
Disclaimer These postings are provided "AS IS" with no warranties, and confer no rights.