internal static extern bool MoveFileTransacted( [In] string lpExistingFileName, [In] string lpNewFileName, [In] IntPtr lpProgressRoutine, [In] IntPtr lpData, [In] MoveFileFlags dwFlags, [In] KtmTransactionHandle hTransaction);
public static void MoveFile(string existingFileName, string newFileName, MoveFileFlags flags) { if (!MoveFileEx(existingFileName, newFileName, (uint)flags)) { ThrowLastWin32Exception(); } }
internal static extern bool MoveFileTransacted( [In, MarshalAs(UnmanagedType.LPWStr)] string lpExistingFileName , [In, MarshalAs(UnmanagedType.LPWStr)] string lpNewFileName , [In] IntPtr lpProgressRoutine , [In] IntPtr lpData , [In] MoveFileFlags dwFlags , [In] KtmTransactionHandle hTransaction);
public static void MoveFile(string existingFileName, string newFileName, MoveFileFlags flags) { if (!MoveFileEx(existingFileName, newFileName, (uint)flags)) { ThrowLastWin32Exception($"Failed to move '{existingFileName}' to '{newFileName}'"); } }
private void buttonExecute_Click(object sender, EventArgs e) { string sourcePath = this.textBoxSourceFileName.Text; string targetPath = (this.checkBoxIsNull.Checked) ? null : Path.Combine(this.textBoxTargetFolder.Text, Path.GetFileName(sourcePath)); MoveFileFlags flags = GetMoveFileOptions(); var result = NativeMethods.MoveFileEx(sourcePath, targetPath, flags); if (result) { MessageBox.Show("Success!"); } else { MessageBox.Show($"Failed (0x{NativeMethods.GetLastError():x8})"); } }
// hook function public static bool MoveFileExW_Hook( string lpExistingFileName, string lpNewFileName, MoveFileFlags dwFlags) { try { if ((lpExistingFileName != null) || (lpExistingFileName.Length > 0)) { if ((lpNewFileName != null) || (lpNewFileName.Length > 0)) { reportEvent(MoveFileExWStr, lpExistingFileName, lpNewFileName); } } } catch { // swallow exceptions so that any issues caused by this code do not crash target process } return(MoveFileW(lpExistingFileName, lpNewFileName)); }
internal static extern bool MoveFileEx(string srcFileName, string destFileName, MoveFileFlags flags);
private static extern bool MoveFileEx(string lpExistFileName, string lpNewFileName, MoveFileFlags flags);
static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, MoveFileFlags dwFlags);
internal static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, MoveFileFlags dwFlags); //Mark for deletion
private static bool MoveFileEx(string source, string destination, MoveFileFlags flags) { return(Kernel32.MoveFileEx(source, destination, flags)); }
public static extern bool MoveFileExW([In, MarshalAs(LPWStr)] string lpExistingFileName, [In, MarshalAs(LPWStr)] string lpNewFileName, [In, MarshalAs(U4)] MoveFileFlags dwFlags);
public static extern bool MoveFileEx( string lpExistingFilename, string lpNewFileName, MoveFileFlags flags);
public static extern Boolean MoveFileWithProgress([NotNull] String lpExistingFileName, [NotNull] String lpNewFileName, CopyProgressRoutine lpProgressRoutine, IntPtr lpData, MoveFileFlags dwCopyFlags);
public static extern Boolean CopyFileEx([NotNull] String lpExistingFileName, [NotNull] String lpNewFileName, [CanBeNull] CopyProgressRoutine lpProgressRoutine, IntPtr lpData, ref Int32 IsCancelled, MoveFileFlags dwCopyFlags);
public void MoveFileEx(string oldFilename, string newFilename, MoveFileFlags moveFlags) { Kernel32.MoveFileEx(oldFilename, newFilename, moveFlags); }
private static extern bool MoveFileWithProgressA(string existingfile, string newfile, CopyProgressRoutine progressRoutine, IntPtr lpData, MoveFileFlags flags);
internal static extern bool MoveFileEx(string existingFileName, string newFileName, MoveFileFlags moveFileFlags);
public static extern bool MoveFileWithProgressW([In, MarshalAs(LPWStr)] string lpExistingFileName, [In, MarshalAs(LPWStr)] string lpNewFileName, [In] CopyProgressRoutine lpProgressRoutine, [In] IntPtr lpData, [In, MarshalAs(U4)] MoveFileFlags dwFlags);
static extern bool MoveFileWithProgress( string existingFileName, string destinationFileName, CopyProgressRoutine progressRoutine, IntPtr notNeeded, MoveFileFlags CopyFlags);
public static extern bool MoveFileEx( [In] string lpExistingFileName, [In] string lpNewFileName, [In] MoveFileFlags dwFlags);
internal static extern bool MoveFileEx([In] string existingFileName, [In] string newFileName, [In] MoveFileFlags flags);
internal static extern bool MoveFileWithProgress(string lpExistingFileName, string lpNewFileName, CopyProgressRoutine lpProgressRoutine, IntPtr lpData, MoveFileFlags dwCopyFlags);
public static bool MoveFileEx(string fileName, string newFileName, MoveFileFlags flags) { return(MoveFileExInternal(fileName, null, MoveFileFlags.DelayUntilReboot)); }
public static extern bool MoveFileWithProgress(string lpExistingFileName, string lpNewFileName, CopyProgressRoutine lpProgressRoutine, IntPtr lpData, MoveFileFlags dwFlags);
public static extern Boolean MoveFileEx(String lpExistingFileName, String lpNewFileName, MoveFileFlags dwFlags);
internal static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, MoveFileFlags dwFlags);
public static void MoveFile(string SourceFilePath, string DestinationFilePath, MoveFileFlags Flags) { if (!Win32.MoveFileEx(SourceFilePath, DestinationFilePath, Flags)) { throw new Win32Exception(Marshal.GetLastWin32Error(), "Failed to move file"); } }