Example #1
0
 internal static extern bool MoveFileTransacted(
     [In] string lpExistingFileName,
     [In] string lpNewFileName,
     [In] IntPtr lpProgressRoutine,
     [In] IntPtr lpData,
     [In] MoveFileFlags dwFlags,
     [In] KtmTransactionHandle hTransaction);
Example #2
0
 public static void MoveFile(string existingFileName, string newFileName, MoveFileFlags flags)
 {
     if (!MoveFileEx(existingFileName, newFileName, (uint)flags))
     {
         ThrowLastWin32Exception();
     }
 }
Example #3
0
 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);
Example #4
0
 public static void MoveFile(string existingFileName, string newFileName, MoveFileFlags flags)
 {
     if (!MoveFileEx(existingFileName, newFileName, (uint)flags))
     {
         ThrowLastWin32Exception($"Failed to move '{existingFileName}' to '{newFileName}'");
     }
 }
Example #5
0
        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);
Example #8
0
 private static extern bool MoveFileEx(string lpExistFileName, string lpNewFileName, MoveFileFlags flags);
Example #9
0
 static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, MoveFileFlags dwFlags);
Example #10
0
 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));
 }
Example #12
0
 public static extern bool MoveFileExW([In, MarshalAs(LPWStr)] string lpExistingFileName, [In, MarshalAs(LPWStr)] string lpNewFileName, [In, MarshalAs(U4)] MoveFileFlags dwFlags);
Example #13
0
 public static extern bool MoveFileEx(
     string lpExistingFilename, string lpNewFileName, MoveFileFlags flags);
Example #14
0
 public static extern Boolean MoveFileWithProgress([NotNull] String lpExistingFileName, [NotNull] String lpNewFileName, CopyProgressRoutine lpProgressRoutine, IntPtr lpData,
                                                   MoveFileFlags dwCopyFlags);
Example #15
0
 public static extern Boolean CopyFileEx([NotNull] String lpExistingFileName, [NotNull] String lpNewFileName, [CanBeNull] CopyProgressRoutine lpProgressRoutine, IntPtr lpData, ref Int32 IsCancelled,
                                         MoveFileFlags dwCopyFlags);
Example #16
0
 public void MoveFileEx(string oldFilename, string newFilename, MoveFileFlags moveFlags)
 {
     Kernel32.MoveFileEx(oldFilename, newFilename, moveFlags);
 }
Example #17
0
 private static extern bool MoveFileWithProgressA(string existingfile, string newfile,
                                                  CopyProgressRoutine progressRoutine, IntPtr lpData, MoveFileFlags flags);
Example #18
0
 internal static extern bool MoveFileEx(string existingFileName, string newFileName, MoveFileFlags moveFileFlags);
Example #19
0
 public void MoveFileEx(string oldFilename, string newFilename, MoveFileFlags moveFlags)
 {
     Kernel32.MoveFileEx(oldFilename, newFilename, moveFlags);
 }
Example #20
0
 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);
Example #21
0
 static extern bool MoveFileWithProgress(
     string existingFileName,
     string destinationFileName,
     CopyProgressRoutine progressRoutine,
     IntPtr notNeeded,
     MoveFileFlags CopyFlags);
Example #22
0
 internal static extern bool MoveFileEx(string existingFileName, string newFileName, MoveFileFlags moveFileFlags);
Example #23
0
 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);
Example #26
0
 public static bool MoveFileEx(string fileName, string newFileName, MoveFileFlags flags)
 {
     return(MoveFileExInternal(fileName, null, MoveFileFlags.DelayUntilReboot));
 }
Example #27
0
 public static extern bool MoveFileWithProgress(string lpExistingFileName, string lpNewFileName, CopyProgressRoutine lpProgressRoutine, IntPtr lpData, MoveFileFlags dwFlags);
Example #28
0
 public static extern Boolean MoveFileEx(String lpExistingFileName, String lpNewFileName, MoveFileFlags dwFlags);
 internal static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, MoveFileFlags dwFlags);
Example #30
0
 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");
     }
 }