public void CreateFileTransactedTest() { using (TxF.Transaction transaction = new TxF.Transaction(false)) { File actual = File.CreateFile("c:\\tmp\\out.txt", File.CreationDisposition.CreatesNewfileIfNotExist, transaction); transaction.Commit(); } }
public void SetAttributesTest() { using (TxF.Transaction transaction = new TxF.Transaction(false)) { string pathFile = @"c:\Progetti\WIN\System.IO.Transactions.TxF\TestFiles\TestFile.zip"; File.SetAttributes(pathFile, TxF.File.FileAttributes.Archive | File.FileAttributes.Compressed, transaction); transaction.Commit(); } }
public void GetAttributesTest() { System.IO.FileAttributes zz = System.IO.File.GetAttributes(@"c:\Progetti\WIN\System.IO.Transactions.TxF\TestFiles\TestFile.zip"); using (TxF.Transaction transaction = new TxF.Transaction(false)) { string pathFile = @"c:\Progetti\WIN\System.IO.Transactions.TxF\TestFiles\TestFile.zip"; TxF.File.FileAttributes result = File.GetAttributes(pathFile, transaction); } }
public void FindTest() { string fileName = @"c:\Progetti\WIN\System.IO.Transactions.TxF\TestFiles\TestFile1.*"; using (TxF.Transaction transaction = new TxF.Transaction(false)) { string[] actual; actual = File.Find(fileName, transaction); } }
public void CreateHardLinkTest() { string pathHardLinkFile = @"c:\tmp\TestFile_HL.zip"; string pathFile = @"c:\Progetti\WIN\System.IO.Transactions.TxF\TestFiles\TestFile.zip"; using (TxF.Transaction transaction = new TxF.Transaction(false)) { File.CreateHardLink(pathHardLinkFile, pathFile, transaction); transaction.Commit(); } }
public void CopyTest() { string sourceFileName = @"c:\tmp\System.IO.Transactions.TxF\TestFiles\TestFile.source"; string destFileName = @"c:\tmp\System.IO.Transactions.TxF\TestFiles\TestFile.dest"; bool overwrite = true; using (TxF.Transaction transaction = new TxF.Transaction(false)) { File.Copy(sourceFileName, destFileName, overwrite, transaction); transaction.Commit(); } }
public void ReadFileTest() { string file = "c:\\tmp\\Test.rar"; byte[] actual; actual = File.ReadFile(file); using (TxF.Transaction transaction = new TxF.Transaction(false)) { File f = File.CreateFile("c:\\tmp\\out.bin", File.CreationDisposition.CreatesNewfileAlways, transaction); int result = File.WriteFile(f, actual); transaction.Commit(); } }
public void CreateDirectoryTest() { using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope()) { string path = "c:\\tmp\\TestFolder"; Directory.CreateDirectory(path, true); ts.Complete(); } using (TxF.Transaction t = new TxF.Transaction()) { string path = "c:\\tmp\\TestFolder2"; Directory.CreateDirectory(path, false, t); t.Commit(); } }
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(); } }