C#操作DOS命令,並擷取處理傳回值

來源:互聯網
上載者:User

標籤:傳回值   state   show   描述   getc   系統   put   box   dex   

// /*----------------// // 檔案名稱:Method// // 檔案功能描述:// //    使用 ADB 來進行安卓裝置與PC端之間的檔案互動,具體adb命令操作請百度查閱// //// // 建立標識:20140526// //// // 修改標識:// // 修改描述:

// //----------------------------------------------------------------*/

                        string cmd = Directory.GetCurrentDirectory();            cmd = cmd.Substring(0, cmd.IndexOf("bin\\")) + @"platform-tools\adb.exe";            ProcessStartInfo psi = new ProcessStartInfo(cmd, "get-state");             psi.CreateNoWindow = true;//不顯示dos命令列視窗            psi.RedirectStandardOutput = true;//            psi.RedirectStandardInput = true;//               psi.UseShellExecute = false;//是否指定作業系統外殼進程啟動程             Process p = Process.Start(psi);            StreamReader reader = p.StandardOutput;//截取輸出資料流               string line = reader.ReadLine();//每次讀取一行            //while (!reader.EndOfStream)            //{            // Console.Out.WriteLine(line);            // line = reader.ReadLine();            //}            if (!line.Equals("device"))            {                MessageBox.Show("裝置未就緒,請查看資料線是否正常串連電腦後重試", "裝置未就緒", MessageBoxButtons.OK, MessageBoxIcon.Error);                return;            }             Directory.CreateDirectory("d://file");            psi.Arguments="pull /sdcard/file/ d:/file";            p = Process.Start(psi);            p.WaitForExit();            p.Close();//關閉進程               reader.Close();//關閉流 

C#操作DOS命令,並擷取處理傳回值

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.