private void copy_one_file(FileInfoEx source_info, string destination_file) { //check mask if (!Wildcard.Match(initial_mask, source_info.FileName)) { return; } var success = false; //now prepare callback buffer if (callback_data != IntPtr.Zero) { Marshal.FreeHGlobal(callback_data); } callback_data = IOhelper.strings_to_buffer(source_info.FullName, destination_file); //prepare uni names var source_uni = IOhelper.GetUnicodePath(source_info.FullName); var dest_uni = IOhelper.GetUnicodePath(destination_file); //string source_uni = source_info.FullName; //string dest_uni = destination_file; //and call CopyFileEx first time var res = WinApiFS.CopyFileEx (source_uni, dest_uni, copy_progress_routine_delegate_holder, callback_data, IntPtr.Zero, copyFileEx_options); if (res == 0) { var win_err = Marshal.GetLastWin32Error(); //process win_err and do second take if needed var temp_copy_options = copyFileEx_options; if (process_CopyFileEx_errors(source_info, destination_file, win_err, ref temp_copy_options)) { //second take res = WinApiFS.CopyFileEx (source_uni, dest_uni, copy_progress_routine_delegate_holder, callback_data, IntPtr.Zero, temp_copy_options); if (res == 0) { win_err = Marshal.GetLastWin32Error(); var win_ex_2 = new Win32Exception(win_err); if (!process_error (string.Format (Options.GetLiteral(Options.LANG_CANNOT_COPY_0_ARROW_1), source_info.FullName, destination_file), win_ex_2)) { stop(); } } else { success = true; } } }//end of res==0 brunch else { //copy success success = true; } if (success) { //update counts total_bytes_transferred += current_file_bytes_transferred; current_file_bytes_transferred = 0; total_files_copied++; //time to notify current panel -> unset selection var e_file_done = new ItemEventArs(source_info.FileName); OnCopyItemDone(e_file_done); //set sec attributes if needed if ((options & CopyEngineOptions.CopySecurityAttributes) == CopyEngineOptions.CopySecurityAttributes) { try { File.SetAccessControl(destination_file, File.GetAccessControl(source_info.FullName)); } catch (Exception ex) { if (!process_error (string.Format (Options.GetLiteral(Options.LANG_CANNOT_SET_SEC_ATTRIBUTES_0), destination_file), ex)) { stop(); } } } } }