public CommandResult Copy(List <FileOperation> lstItems, enCopyType ct, bool showProgress = false) { foreach (FileOperation fileOperation in lstItems) { string sourceValid = string.Format("\"{0}\"", fileOperation.Source); string destinationValid = fileOperation.Destination/*.Replace(":", "_")*/ .Replace("*", "_") .Replace("?", "_") .Replace("<", "_") .Replace(">", "_") .Replace("|", "_") .Replace("\"", "_"); string type = ct == enCopyType.Pull ? "pull" : "push"; bool bProgress = showProgress; if (ct == enCopyType.Copy) { type = "shell cp -a"; bProgress = false; destinationValid = destinationValid.Replace(" ", "\\ ") .Replace("(", "\\(") .Replace(")", "\\)") .Replace("'", "\\'") .Replace("&", "\\&"); sourceValid = sourceValid.Replace(" ", "\\ ") .Replace("(", "\\(") .Replace(")", "\\)") .Replace("'", "\\'") .Replace("&", "\\&"); } string runCommand = string.Format("{0}{1} {2}", type, bProgress ? " -p" : string.Empty, sourceValid) + " " + string.Format("\"{0}\"", destinationValid); if (ct == enCopyType.Push) { if (fileOperation.IsFolder && fileOperation.IsFolderEmpty) { string dirValid = fileOperation.Destination.Replace(" ", "\\ ") .Replace("(", "\\(") .Replace(")", "\\)") .Replace("'", "\\'") .Replace("&", "\\&"); runCommand = string.Format(COMMAND_NEWDIR, dirValid); } } fileOperation.Command = SelectDevice(runCommand); } ADBRunner runner = new ADBRunner(); bool bret = runner.LaunchProcess(lstItems, CommandDialog.Copy, showProgress); return(new CommandResult(runner.strMessage, bret)); }
public CommandResult Copy(string source, string destination, enCopyType ct, bool showProgress = false) { ADBRunner runner = new ADBRunner(); string sourceValid = string.Format("\"{0}\"", source); string destinationValid = destination /*.Replace(":", "_") * .Replace("*", "_") * .Replace("?", "_") * .Replace("<", "_") * .Replace(">", "_") * .Replace("|", "_") * .Replace("\"", "_")*/; string type = ct == enCopyType.Pull ? "pull" : "push"; if (ct == enCopyType.Copy) { type = "shell cp"; showProgress = false; } string runCommand = string.Format("{0} {1} {2}", type, showProgress ? "-p" : string.Empty, sourceValid) + " " + string.Format("\"{0}\"", destinationValid); bool bret = runner.LaunchProcess(SelectDevice(runCommand), CommandDialog.Copy, showProgress, destination); return(new CommandResult(runner.strMessage, bret)); }