private void timer1_Tick(object sender, EventArgs e) { if (Process.GetProcessesByName(SoftName).Length == 0) { if (flag == true) { return; } flag = true; if (File.Exists(AppPath)) { File.Delete(AppPath); } FtpDownload(AppPath.Substring(0, AppPath.LastIndexOf("\\")), "汽车模型信息管理.exe", "192.168.1.252", "zhao", "123abc"); string NewFileMD5 = UserFunction.GetMD5HashFromFile(AppPath); string updatestr = "update [VerList] set MD5 = '" + NewFileMD5 + "' where 版本号 =(select TOP 1 版本号 from [VerList] where 程序名 = '汽车模型信息管理' order by 版本号 desc)"; DatabaseCmd cmd = new DatabaseCmd(); cmd.SqlExecuteNonQuery(updatestr); Process ps = new Process(); ps.StartInfo.FileName = AppPath; ps.Start(); Application.Exit(); } }