No, you cannot make arbitrary code transactional by running it inside a TransactionScope
.
As you noted in a comment, the System.Transactions
namespace provides infrastructure classes to help make any resource transactional. By default, .NET provides resource manager support for several kinds of operations, listed in the namespace introduction you linked (in a comment): "SQL Server, ADO.NET, MSMQ, and the Microsoft Distributed Transaction Coordinator (MSDTC)."
It turns out, there is support for file system transactions - though I could only find it for NTFS (Enhance Your Apps With File System Transactions). For my money, that code could seriously use a façade, though. ;) Perhaps there are other, more generalized implementations out there (or perhaps not - making file IO transactional may require the extra infrastructure NTFS provides).
There's also a fair amount of ongoing research on making changes to in-memory state transactional, called software transactional memory. Microsoft DevLabs offers an implementation: STM.NET.