I'm using WinXP on clients and Win2003 on a server.
I need do atomic actions: create-moving files, insert-update database.
Are there any good practices for file system transactions using WinXP? I know in Vista/Win2008/Win7 there are TxF transaction (NTFS) but not in WinXP.
I don't want use COM+, neither other complex solutions. Only need good sample code, for good practices.
Transactions and file-actions by Alberto Poblacion
In versions of Windows earlier than Vista, the filesystem is not transactional, so you need a separate tool to do transactions on your files.
You could use Component Services (COM+) to implement a Compensating Resource Manager (CRM). The CRM will provide the transaction log and will roll back changes during a system restart if it crashed during the update of your files, but you will have to provide the code (in your own DLL) to commit and rollback the transation, typically by means of moving files in and out of a temp folder. It can all be done in .Net by means of the System.EnterpriseServices namespace. If I recall correctly, Microsoft Official Course 2557 contains a chapter that teaches how to create a CRM, and the example that they use is built precisely on changes to the filesystem.
In newer versions of Windows, you can do transactional operations on NTFS:
http://msdn.microsoft.com/en-us/library/bb986748(VS.85).aspx