/// <summary>
        /// 下载最新版,初始化连接字符串.
        /// </summary>
        /// <returns></returns>
        public static bool downloadTheLatestVersionAndInitConnStr()
        {
            //=====================================================================
            // Project Name        :    BaseDao
            // Project Description :
            // Class Name          :    Class1
            // File Name           :    Class1
            // Namespace           :    BaseDao
            // Class Version       :    v1.0.0.0
            // Class Description   :
            // CLR                 :    4.0.30319.42000
            // Author              :    董   魁  ([email protected])
            // Addr                :    中国  陕西 咸阳
            // Create Time         :    2019-10-22 14:57:19
            // Modifier:
            // Update Time         :    2019-10-22 14:57:19
            //======================================================================
            // Copyright © DGCZ  2019 . All rights reserved.
            // =====================================================================
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            if (!File.Exists(Application.StartupPath + "\\flexflow.cfg"))
            {
                MessageBox.Show(string.Format(@"文件:{0},未找到!", Application.StartupPath + "\\flexflow.cfg"), "提示:", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
            XmlFlexflow.configFilePath = Application.StartupPath + "\\flexflow.cfg";
            string ftpIPADDR = XmlFlexflow.ReadXmlNodeValue("FTP_IPADDR");

            releaseVersion = string.Empty;
            //先测试是否可以ping通
            if (!ConnectByPing.pingTheAddress(ftpIPADDR))
            {
                MessageBox.Show("未能与版本服务器: " + ftpIPADDR + "取得联系!", "提示: ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
            //检查软件版本
            MSG msg = CheckAppVerionByFTP.checkAppVersionAndOutReleaseVersion(ftpIPADDR, out releaseVersion);

            if (!msg.Flag)
            {
                if (!msg.Msg.Contains("更新"))
                {
                    return(false);
                }
                //自动升级。
                //判断是否存在update文件
                if (!Directory.Exists(Application.StartupPath + "\\update"))
                {
                    //给出提示:
                    MessageBox.Show("未发现升级目录: " + Application.StartupPath + "\\update", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(false);
                }
                //进行升级
                CmdHelper.LaunchBatOrExe(string.Format(@"{0}\update\UpdateProgram.exe", Application.StartupPath), Application.ProductName + " " + releaseVersion);
                //进行升级时,也需要退出,防止覆盖时,提示文件正在使用中。
                return(false);
            }
            return(true);
        }
 /// <summary>
 /// 检查软件目录是否存在
 /// </summary>
 /// <param name="appName"></param>
 /// <returns></returns>
 public static bool ifExistsTheDirOfSoftware(string appName)
 {
     if (!ifExistsBatFileOfConnShare())
     {
         return(false);
     }
     //1.建立连接
     //建立连接
     CmdHelper.LaunchBatOrExe(string.Format(@"{0}\update\connShare.bat", Application.StartupPath));
     if (!Directory.Exists(string.Format(@"S:\{0}", appName)))
     {
         MessageBox.Show(string.Format(@"软件{0}: 在共享目录上尚未发布!", appName), "提示: ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         //断开连接
         CmdHelper.LaunchBatOrExe(string.Format(@"{0}\update\deleteShare.bat", Application.StartupPath));
         return(false);
     }
     return(true);
 }
        /// <summary>
        /// 检查程序版本号。
        /// </summary>
        /// <param name="softwareName"></param>
        /// <param name="version"></param>
        /// <returns></returns>
        public static bool checkSoftVersion(string softwareName, string currVersion)
        {
            if (!ifExistsBatFileOfConnShare())
            {
                return(false);
            }
            //1.建立连接
            //建立连接
            CmdHelper.LaunchBatOrExe(string.Format(@"{0}\update\connShare.bat", Application.StartupPath));
            string resultStr = FileHelper.readFile(string.Format(@"S:\version.txt"));

            string[] strArray       = { "\r\n" };
            string[] resultStrArray = resultStr.Split(strArray, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < resultStrArray.Length; i++)
            {
                //再次分解
                string   tempStr          = resultStrArray[i].ToString();
                string[] versionInfoArray = tempStr.Split(':');
                if (!softwareName.Equals(versionInfoArray[0].Trim()))
                {
                    continue;
                }
                //检查版本号
                string releaseVersion = versionInfoArray[1].Trim();
                if (!currVersion.Equals(releaseVersion))
                {
                    MessageBox.Show(string.Format(@"当前版本{0} 与发布的版本{1} 不一致,需更新!", currVersion, releaseVersion), "提示: ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(false);
                }
                else
                {
                    //版本信息一致
                    return(true);
                }
            }
            //未找到
            MessageBox.Show(string.Format(@"此程序名{0}:未在version.txt中注册!", softwareName), "提示!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            return(false);
        }