Is there any file system transaction mechanism for a .net application?

I implement a simple update mechanism for the application that I am writing, the last part of the update process is to rename the current application executable from something like myApp.exe to myApp.old.exe, and then rename the downloaded and updated file from myApp.new. exe in myApp.exe.

I would like to find a way for the two operations to be atomic, because if my application crashes (for some reason, like asteroids falling on a power line) after it renamed itself and before it renamed the new version, it will get stuck in a state where it cannot be restarted using regular shortcuts, so it will not be able to complete its update.

So, is there a way to make the upgrade fail-safe?

+5
source share
1 answer

In 2008 / Vista up yes, although it is not exposed. At this point, NTFS received file system / file system / kernel transactions.

Please check:

http://www.michaelckennedy.net/blog/2007/12/07/SystemTransactionsAndWindowsVistaNTFSUpdated.aspx

http://www.codeguru.com/cpp/misc/misc/fileio/article.php/c9987

http://xavierdecoster.wordpress.com/2009/10/18/transactional-ntfs-txf/

They have code samples.

+2
source

All Articles