Microsoft.KtmIntegration.TransactedFile.Move C# (CSharp) Method

Move() public static method

public static Move ( string sourceFileName, string destFileName ) : bool
sourceFileName string
destFileName string
return bool
        public static bool Move(string sourceFileName, string destFileName)
        {
            using (TransactionScope scope = new TransactionScope())
            using (KtmTransactionHandle ktmTx = KtmTransactionHandle.CreateKtmTransactionHandle())
            {
                // Allow copying to different volumes and to replace existing files
                NativeMethods.MoveFileFlags moveFlags =
                    NativeMethods.MoveFileFlags.MOVEFILE_COPY_ALLOWED |
                    NativeMethods.MoveFileFlags.MOVEFILE_REPLACE_EXISTING;

                bool status = NativeMethods.MoveFileTransacted(
                    sourceFileName,
                    destFileName,
                    IntPtr.Zero,
                    IntPtr.Zero,
                    moveFlags,
                    ktmTx);

                if (!status)
                {
                    NativeMethods.HandleCOMError(Marshal.GetLastWin32Error());
                }

                scope.Complete();
                return status;
            }
        }