private OperationResult ExecuteCopy(QueueItem queueitem, CopyAction?action, string rename)
        {
            var            item       = queueitem.FileSystemItem;
            var            sourcePath = item.GetRelativePath(SourcePane.CurrentFolder.Path);
            var            targetPath = TargetPane.GetTargetPath(sourcePath);
            TransferResult result;

            switch (item.Type)
            {
            case ItemType.Directory:
            case ItemType.Link:
                if (TargetPane.CreateFolder(targetPath) == TransferResult.Ok)
                {
                    var       i = 1;
                    QueueItem qi;
                    while (i < _queue.Count && (qi = _queue.ElementAt(i)) != null && qi.FileSystemItem.Path.StartsWith(item.Path))
                    {
                        qi.CopyAction = CopyAction.Overwrite;
                        i++;
                    }
                }
                result = TransferResult.Ok;
                break;

            case ItemType.File:
                if (action == CopyAction.Rename && !string.IsNullOrEmpty(rename))
                {
                    var r = new Regex(string.Format(RenameFromPattern, item.Name), RegexOptions.IgnoreCase);
                    targetPath = r.Replace(targetPath, string.Format(RenameToPattern, rename));
                    action     = CopyAction.CreateNew;
                }

                var a = action ?? _rememberedCopyAction;

                FileMode          mode;
                FileExistenceInfo exists;
                long startPosition = 0;
                switch (a)
                {
                case CopyAction.CreateNew:
                    //TODO: check what happens if targetPath contains spec.char
                    exists = TargetPane.FileExists(targetPath);
                    if (exists)
                    {
                        throw new TransferException(TransferErrorType.WriteAccessError, Resx.TargetAlreadyExists)
                              {
                                  SourceFile     = item.Path,
                                  TargetFile     = targetPath,
                                  TargetFileSize = exists.Size
                              }
                    }
                    ;
                    mode = FileMode.CreateNew;
                    break;

                case CopyAction.Overwrite:
                    mode = FileMode.Create;
                    break;

                case CopyAction.OverwriteSmaller:
                    var target = TargetPane.FileExists(targetPath);
                    if (target.Exists && target.Size >= item.Size)
                    {
                        return(new OperationResult(TransferResult.Skipped, targetPath));
                    }
                    mode = FileMode.Create;
                    break;

                case CopyAction.Resume:
                    mode   = FileMode.Append;
                    exists = TargetPane.FileExists(targetPath);
                    if (exists)
                    {
                        startPosition = exists.Size;
                    }
                    break;

                default:
                    throw new ArgumentException("Invalid Copy action: " + action);
                }

                UIThread.Run(() => { TransferAction = GetCopyActionText(); });

                switch (_remoteCopy)
                {
                case RemoteCopyMode.Disabled:
                    using (var targetStream = TargetPane.GetStream(targetPath, mode, FileAccess.Write, startPosition))
                    {
                        result = SourcePane.CopyStream(item, targetStream, startPosition) ? TransferResult.Ok : TransferResult.Aborted;
                    }
                    break;

                case RemoteCopyMode.Download:
                    var sourceName = RemoteChangeDirectory(item.Path);
                    Telnet.Download(sourceName, targetPath, item.Size ?? 0, startPosition, (p, t, total, sp) => OnTransferProgressChanged(new TransferProgressChangedEventArgs(p, t, total, sp)));
                    result = TransferResult.Ok;
                    break;

                case RemoteCopyMode.Upload:
                    var targetName = RemoteChangeDirectory(targetPath);
                    Telnet.Upload(targetName, item.Path, item.Size ?? 0, startPosition, (p, t, total, sp) => OnTransferProgressChanged(new TransferProgressChangedEventArgs(p, t, total, sp)));
                    result = TransferResult.Ok;
                    break;

                default:
                    throw new NotSupportedException();
                }
                break;

            default:
                throw new NotSupportedException();
            }
            return(new OperationResult(result, targetPath));
        }