Geeks With Blogs
Adrian Hara Working through the .NET maze
Even though I heart about transactional file system support since Vista, I never really tried it. So needing to do it today I looked up ways to use it from the managed world. Turns out it's not so straightforward...

In the Vista RC, to use the transactional fs support what you'd have to do is just call some win32 api methods that would signal the file system functions that there's a transaction going on. So basically you would whip up a TransactionScope, call the win32 api to set the "transaction-aware" flag, work with some file functions, call the win32 api again to reset the flag, and commit the scope. Here's how:

Well, in later releases it was decided (probably for good reasons) that this wasn't the way to go, so what happened was that most (if not all) the win32 file apis got some "-Transacted" counterparts, like CreateFileTransacted, DeleteFileTransacted etc. Also, to be able to use all these from managed code, you'd have to interop with the Kernel Transaction Manager. You can find a pretty good write-up of all this here: . Jim Johnson also blogs about this here:

I was just about to go and write the nitty-gritty myself, when I stumbled across this gem: . AlphaFS provides all the transactional file system support for .net you'll ever need, and more! Even though AlphaFS is still beta (no pun intended), it worked out-of-the-box quite well. Granted, I only did some simple stuff, like traversing some directory structure and manipulating stuff along the way (creates, deletes, attributes etc), but it's all good. While there are some minor issues, like no built-in methods for recursively doing stuff (DeleteDirectoryRecursive anyone?) or some performance hit (which is to be expected from a transactional fs), the library is really great and I'd like to extend my congratulations to the folks that wrote it. So... enjoy :)

Posted on Tuesday, October 13, 2009 11:39 AM | Back to top

Comments on this post: Using the transactional file system in Vista+ from managed code

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Adrian Hara | Powered by: