0
Я новичок в C# и стараюсь, как работает TransactionScope. Вот мой код, и я удивляюсь, почему моя сделка не отката:C# TransactionScope не откат
string file1 = "txf1.txt";
string file2 = "txf2.txt";
using (StreamWriter sw = File.CreateText(file1))
{
sw.WriteLine("Hello World");
}
using (StreamWriter sw = File.CreateText(file2))
{
sw.WriteLine("Hello World");
}
using (TransactionScope scope = new TransactionScope())
{
File.AppendAllText(file1, "Transaktion");
scope.Complete();
}
using (TransactionScope scope = new TransactionScope())
{
File.AppendAllText(file2, "Transaktion");
//should roll back the file, but doesn't
}