C # Operation DOS command, and get processing return value

Source: Internet
Author: User

/*----------------////File name: method/////File Function Description:////////////use ADB for file interaction between Android device and PC side, specific ADB command operation please Baidu check////////Create Logo: 2014052 6////////Modify the Logo:///Modify the Description:

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

                        string cmd = Directory.getcurrent Directory ();            cmd = cmd. Substring (0, CMD. IndexOf ("bin\\")) + @ "Platform-tools\adb.exe";            ProcessStartInfo psi = new Process StartInfo (cmd, "get-state");             PSI. CreateNoWindow = true;//does not display DOS command line window             PSI. Redirectstandardoutput = true;//            PSI. Redirectstandardinput = true;//            PSI. UseShellExecute = false;//Specifies whether the operating system Shell process initiation process              Process P = process.start (PSI); nbsp           StreamReader reader = p.standardoutput;//intercept output stream           &NB Sp String line = reader. ReadLine ();//read one line at a time            //while (!reader. EndOFStream)            //{           //Console.Out.WriteLine (li NE);           //line = reader. ReadLine ();           //}            if (!line. Equals ("Device"))             {                MESSAG Ebox.show ("The device is not ready, please check that the data cable is properly connected to the computer and try again", "Device Not Ready", MessageBoxButtons.OK, Messageboxicon.error);                return;           }         &NB Sp   Directory.CreateDirectory ("D://file");            PSI. arguments= "Pull/sdcard/file/d:/file";            p = Process.Start (PSI);    &NBS P       p.WaitForExit ();            p.close ();//close process       &NB Sp     Reader. Close ();//Closed Flow  

C # Operation DOS command, and get processing return value

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.