public void WriteFileTest() { byte[] data = System.IO.File.ReadAllBytes("c:\\tmp\\test.rar"); using (TxF.Transaction transaction = new TxF.Transaction(false)) { try { File actual = File.CreateFile("c:\\tmp\\out.bin", File.CreationDisposition.CreatesNewfileAlways, transaction); int result = File.WriteFile(actual, data); transaction.Commit(); } catch (FileTransactedException) { transaction.Rollback(); throw; } finally { } } }
public void WriteFileTest2() { byte[] data = System.IO.File.ReadAllBytes(@"c:\tmp\System.IO.Transactions.TxF\TestFiles\TestFile.zip"); TxF.Transaction transaction = new TxF.Transaction(false); try { File actual = File.CreateFile("c:\\tmp\\out.bin", File.CreationDisposition.CreatesNewfileAlways, transaction); int result = File.WriteFile(actual, data); transaction.Commit(); } catch (FileTransactedException) { transaction.Rollback(); throw; } finally { transaction.Close(); } }