private MoveFileTransacted ( [ lpExistingFileName, [ lpNewFileName, [ lpProgressRoutine, [ lpData, [ dwFlags, [ hTransaction ) : bool | ||
lpExistingFileName | [ | |
lpNewFileName | [ | |
lpProgressRoutine | [ | |
lpData | [ | |
dwFlags | [ | |
hTransaction | [ | |
Résultat | 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); } }