Ejemplo n.º 1
0
        //获取别名
        public void GetAlisa()
        {
            Process process = InitProcess();

            process.StandardInput.WriteLine("keytool -list  -v -keystore " + mainEntity.SignerPath + " -storepass " + mainEntity.SignerPassword);
            process.StandardInput.WriteLine("exit");

            string strRst = process.StandardOutput.ReadToEnd(); //获取结果

            process.WaitForExit();                              //等待命令结束
            process.Close();                                    //进程结束
            string alias = "";
            int    startIndex;
            int    length;

            if (strRst.Contains("Alias name"))
            {
                startIndex = strRst.IndexOf("Alias name");
                length     = strRst.IndexOf("Creation date");
            }
            else if (strRst.Contains("别名"))
            {
                startIndex = strRst.IndexOf("别名");
                length     = strRst.IndexOf("创建日期");
            }
            else
            {
                MessageBox.Show("签名密码错误");
                return;
            }

            String[] strs = strRst.Substring(startIndex, length).Split(':');
            if (strs != null && strs.Length > 0)
            {
                alias = strs[1];
                //斩头去尾留中间
                alias = alias.Substring(0, alias.IndexOf("\n")).TrimStart().TrimEnd();

                Console.WriteLine("alias is:\n" + alias + alias.Length);
            }
            else
            {
                MessageBox.Show("签名密码错误");
            }
            iProcess.GetAliasEnd(alias);
        }