Exemple #1
0
        } //end of proc

        /// <summary>
        /// work only if source and destination on one volume
        /// </summary>
        /// <param name="source">can be file or dir</param>
        /// <param name="destination">file or dir</param>
        private void move_one_item(FileInfoEx source, string destination)
        {
            //prepare callback buffer
            if (callback_data != IntPtr.Zero)
            {
                Marshal.FreeHGlobal(callback_data);
            }
            callback_data = IOhelper.strings_to_buffer(source.FullName, destination);

            //prepare uni names
            var source_uni      = IOhelper.GetUnicodePath(source.FullName);
            var destination_uni = IOhelper.GetUnicodePath(destination);

            //call update dialog before...
            var e_begin_move = new UpdateProgressArgs();

            e_begin_move.DestinationFile     = destination;
            e_begin_move.EnableTotalProgress = false;
            e_begin_move.Reason     = UpdateProgressReason.StreamSwitch;
            e_begin_move.SourceFile = source.FullName;
            update_progress_safe(e_begin_move);

            //and call MoveFileWithProgress
            var res = WinApiFS.MoveFileWithProgress
                          (source_uni,
                          destination_uni,
                          move_progress_delegate_holder,
                          callback_data,
                          options_api);

            if (res == 0)
            {
                var win_err = Marshal.GetLastWin32Error();
                var win_ex  = new Win32Exception(win_err);
                AbortJobSafe = !process_errors
                                   (string.Format
                                       (Options.GetLiteral(Options.LANG_CANNOT_MOVE_0_ARROW_1),
                                       source,
                                       destination),
                                   win_ex);
                return;
            }
            //success move
            //notify item done - not needed, source item deleted
        }