close
文章出處

C#利用Diagnostics  拉取最新代碼  示例代碼

 

        static void DiagnosticTest()
        {
            Process p;
            ProcessStartInfo psi;
            psi = new ProcessStartInfo("sh.exe");
            psi.Arguments += "--login -i";

            psi.UseShellExecute = false;
            psi.RedirectStandardOutput = true;  //允許重定向標準輸出
            psi.RedirectStandardInput = true;   //接受來自調用程序的輸入信息

            psi.RedirectStandardError = true;
            psi.WindowStyle = ProcessWindowStyle.Hidden;

            p = Process.Start(psi);           
            
            p.StandardInput.WriteLine("cd D://");
            p.StandardInput.WriteLine("cd D:/git/Component/");

            p.OutputDataReceived += new DataReceivedEventHandler(OnDataReceived);            
            p.BeginOutputReadLine();
            p.BeginErrorReadLine();

            //p.StandardInput.WriteLine("git fetch --all");
            //p.StandardInput.WriteLine("git reset --hard origin/master");
            p.StandardInput.WriteLine("git pull");
            p.Close();
        }
        private static void OnDataReceived(object Sender, DataReceivedEventArgs e)
        {
            if (e.Data == "Already up-to-date.")
            {
                Console.WriteLine("已拉取最新的Component代碼");
            }
        }

不含病毒。www.avast.com
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 AutoPoster 的頭像
    AutoPoster

    互聯網 - 大數據

    AutoPoster 發表在 痞客邦 留言(0) 人氣()