Geeks With Blogs

News

Locations of visitors to this page




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: http://www.pluralsight.com/community/blogs/jimjohn/archive/2005/09/13/14803.aspx

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: http://msdn.microsoft.com/en-us/magazine/cc163388.aspx . Jim Johnson also blogs about this here: http://www.pluralsight.com/community/blogs/jimjohn/archive/2006/08/31/36819.aspx

I was just about to go and write the nitty-gritty myself, when I stumbled across this gem: http://alphafs.codeplex.com/ . 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: GeeksWithBlogs.net