日期:2014-05-17  浏览次数:21443 次

在 WebClient 请求期间发生异常,如何处理进程错误?

private static string GetUpdateServerIp()
        {
            XmlDocument xdRead = new XmlDocument();
            string strAppPath = AppDomain.CurrentDomain.BaseDirectory;
            xdRead.Load(strAppPath + "CourtInteTIM.ElisorEesWhs.config");   //XML地址
            XmlElement xnode = (XmlElement)xdRead.SelectSingleNode("/configuration/UpdateImformation");
            return xnode.GetAttribute("UpdateServerIp");
        }
        private static void DownLoadNewFile(string strFileName)
        {
            WebClient webClient = new WebClient();
            webClient.DownloadFile(@"http://" + GetUpdateServerIp() + "/CourtElisorEesWhs/UpdateVission/" + strFileName, @strFileName);
        }
        private static void ReleaseService()//释放服务和进程
        {
            ServiceController service = new ServiceController("CourtInteTIM  RemotingService");
            service.Stop();
            foreach (Process myProcess in Process.GetProcesses())
            {
                if (myProcess.ProcessName.ToUpper().IndexOf("ElisorEesWhs".ToUpper())!=-1)
                {
                    myProcess.Kill();
                    myProcess.Close();
                }
            }
        }
        private static void OpenService()
        {
            ServiceController service = new ServiceController("CourtInteTIM  RemotingService");
            service.Start();
        }
        private static int GetFileVission(string strFilePath)
        {
            string[] astrVission = (Assembly.LoadFrom(strFilePath).GetName().Version.ToString()).