Geeks With Blogs

News
WinToolZone - Spelunking Microsoft Technologies
I work as a developer on the Common Language Runtime (CLR) team, specifically in the areas of exception handling and CLR hosting.
Disclaimer

The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion. Inappropriate comments will be deleted at the authors discretion. All code samples are provided "AS IS" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

Inside and Out... An attempt to understand technology better...

Sometime back, I had made a post regarding a native C++ class I had authored for using some of the Transactional NTFS (TxF)APIs introduced in Windows Vista.

Almost two weeks from that post, I just finished my managed implementation, TransNTFS, that enables you to use the TxF APIs from managed code. As always, Managed C++ enabled the implementation with excellent ease. It comes with complete documentation and can be downloaded from http://www.wintoolzone.com/ListDotNET.aspx?Listtype=3.

Below is an example usage of how to copy a file under a transaction:

.
   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Text;
   4:  using WinToolZone;
   5:   
   6:  namespace ManagedTransactionCopyDemo
   7:  {
   8:  class Program
   9:  {
  10:  static void Main(string[] args)
  11:  {
  12:  TransNTFS refTC = new TransNTFS();
  13:   
  14:  // Init the transaction
  15:  bool fSuccess = refTC.BeginTransaction();
  16:  if (fSuccess)
  17:  {
  18:  fSuccess = refTC.CopyFile("d:\\transcopy.pdb", "d:\\t.pdb", false);
  19:  if (fSuccess)
  20:  {
  21:  fSuccess = refTC.Commit();
  22:  if (fSuccess)
  23:  {
  24:  Console.WriteLine("Copy successful!");
  25:  }
  26:  else
  27:  {
  28:  ShowErrorAndExit("Commit failed!", refTC.LastError);
  29:  }
  30:  }
  31:  else
  32:  {
  33:  ShowErrorAndExit("Copy failed!", refTC.LastError);
  34:  }
  35:  }
  36:  else
  37:  {
  38:  ShowErrorAndExit("Unable to start the transaction!", refTC.LastError);
  39:  }
  40:  }
  41:   
  42:  private static void ShowErrorAndExit(string p, int p_2)
  43:  {
  44:  Console.WriteLine("ERROR: {0}", p);
  45:  Console.WriteLine("CODE: {0}", p_2);
  46:  System.Environment.Exit(1);
  47:  }
  48:  }
  49:  }
Posted on Thursday, March 29, 2007 1:49 PM .NET Framework , Downloads | Back to top


Comments on this post: [Download] TransNTFS - Managed implementation of Transactional NTFS (TxF) APIs

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


Copyright © Gaurav Khanna | Powered by: GeeksWithBlogs.net