File System Transactions Using .NET on WinXP

I use WinXP for clients and Win2003 on the server.

I need to perform atomic actions: create moving files, insert-update database.

Is there any good practice for file system transactions using WinXP? I know that in Vista / Win2008 / Win7 there is a TxF transaction (NTFS), but not in WinXP.

I do not want to use COM + nor other complex solutions. To get good practice, you only need a good code sample.

Transactions and File Actions Alberto Poblacion

On versions of Windows earlier than Vista, the file system is not transactional, so you need a separate tool for making transactions in your files.

You can use Component Services (COM +) to implement a Compensating Resource Manager (CRM). CRM will provide a transaction log and roll back changes during a system reboot if it crashed while updating your files, but you will have to provide code (in your own DLL) to commit and roll back the translation, usually by moving files to and from temporary folder. All of this can be done in .Net using the System.EnterpriseServices namespace. If I remember correctly, Microsoft Official Course 2557 contains a chapter that describes how to create CRM, and the example that they use is built on changes to the file system.

In newer versions of Windows, you can perform transactional operations on NTFS:

http://msdn.microsoft.com/en-us/library/bb986748(VS.85).aspx

http://msdn.microsoft.com/en-us/magazine/cc163388.aspx

http://codeproject.com/KB/vista/VistaKTM.aspx

Change

Literature:

https://transactionalfilemgr.codeplex.com/

http://www.codeproject.com/Articles/690136/All-About-TransactionScope

http://ayende.com/blog/4528/who-stole-my-transaction

http://www.chinhdo.com/20080825/transactional-file-manager/

http://bmegias.wordpress.com/2010/10/25/ejecutar-acciones-al-finalizar-la-transaccion-transactioncompleted-vs-enlistvolatile/

+4
source share
4 answers

You can create your own class that implements IEnlistmentNotification.

Here is an example of whoever did it: http://www.chinhdo.com/20080825/transactional-file-manager/

+2
source

You will not get true file system transactions for NTFS in XP. However, you may not need it.

For example, when installing software, you can pretty much get transaction semantics for free using something like a Windows installer.

What do you ultimately achieve?

0
source

.NET Transactional File Manager should work under XP.

TxF is likely to pull it out of interest from future releases of Windows (some features were deprecated in Win 8).

See How to write a transaction to cover File Transfer and Insert a record in a database? .

0
source

You might want to look at the File.Replace method, which I assume uses transactions because it requires NTFS. http://msdn.microsoft.com/en-us/library/9d9h163f(v=vs.100).aspx

0
source

Source: https://habr.com/ru/post/1307723/


All Articles