Exemplo n.º 1
0
        //相当于LS命令
        public static void Move(string source, string dest)
        {
            if (string.IsNullOrEmpty(dest))
            {
                return;
            }

            MakeDir(dest.Substring(0, dest.LastIndexOf('/')));

            //dest = MakeDir(dest);

            Thread.Sleep(1000);

            // 复制文件
            Process          p2         = new Process();
            ProcessStartInfo startInfo2 = new ProcessStartInfo();

            startInfo2.FileName  = ADB;
            startInfo2.Arguments = MV + AndroidFileNameEncoder.ToUTF8(source)
                                   + MV_SPLIT + AndroidFileNameEncoder.ToUTF8(dest);
            startInfo2.RedirectStandardOutput = true;
            startInfo2.UseShellExecute        = false;
            startInfo2.StandardOutputEncoding = System.Text.Encoding.UTF8;
            startInfo2.CreateNoWindow         = true;

            p2.StartInfo = startInfo2;
            p2.Start();

            return;
        }
Exemplo n.º 2
0
        //从Android设备复制文件
        public static void CopyFromAndroid(string source, string dest)
        {
            Process          p         = new Process();
            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.FileName        = ADB;
            startInfo.Arguments       = PULL + "\"" + AndroidFileNameEncoder.ToUTF8(source) + "\"" + " " + "\"" + dest + "\"";
            startInfo.UseShellExecute = false;
            startInfo.CreateNoWindow  = true;

            p.StartInfo = startInfo;
            p.Start();
        }
Exemplo n.º 3
0
        //相当于LS命令
        public static List <string> Ls(string directory)
        {
            if (string.IsNullOrEmpty(directory))
            {
                return(null);
            }
            if (directory.Substring(directory.Length - 2, 1) != "//")
            {
                directory += "//";
            }

            List <string> files = new List <string>();

            Process          p         = new Process();
            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.FileName  = ADB;
            startInfo.Arguments = LS + AndroidFileNameEncoder.ToUTF8(directory);
            startInfo.RedirectStandardOutput = true;
            startInfo.UseShellExecute        = false;
            startInfo.StandardOutputEncoding = System.Text.Encoding.UTF8;
            startInfo.CreateNoWindow         = true;

            p.StartInfo = startInfo;
            p.Start();

            StreamReader reader = p.StandardOutput;

            for (string tmp = reader.ReadLine(); tmp != null; tmp = reader.ReadLine())
            {
                if (tmp.Equals("\r") || tmp.Equals("\n") || tmp.Equals(""))
                {
                    continue;
                }
                if (tmp.Trim().Length >= 4 &&
                    (tmp.Trim().Substring(tmp.Length - 4, 4).Equals(".txt") || tmp.Trim().Substring(tmp.Length - 4, 4).Equals(".TXT")))
                {
                    files.Add(directory + tmp);
                }
            }

            return(files);
        }