private void MstUpdateApplication_Load(object sender, EventArgs e) { this.Text = J_Var.J_pProjectName; txtBrowser.Text = ""; BtnBrowser.Select(); }
private void BtnUpdate_Click(object sender, EventArgs e) { //+++++++++++++++++++++++++++++++++++++++++++++++++ // R&D to get exe file version //FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(Application.StartupPath + "/" + J_Var.J_pExeFileName + ".exe"); //MessageBox.Show(versionInfo.FileVersion); //+++++++++++++++++++++++++++++++++++++++++++++++++ if (this.J_IsProcessOpen(J_Var.J_pExeFileName) == true) { MessageBox.Show("Application is running.\nPlease close the application.", J_Var.J_pProjectName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } string strSourceFilePath = txtBrowser.Text; if (strSourceFilePath == "" || strSourceFilePath == null) { return; } string strDestinationFolderPath = Application.StartupPath; if (File.Exists(strSourceFilePath) == false) { MessageBox.Show("Selected file does not exist.", J_Var.J_pProjectName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); BtnBrowser.Select(); return; } FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(strSourceFilePath); if (J_Var.J_pExeFileName + ".exe" != Convert.ToString(fileVersionInfo.InternalName)) { MessageBox.Show("Invalid application file.\nPlease select valid application file.", J_Var.J_pProjectName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (this.J_GetDirectoryName(strSourceFilePath).Trim().ToUpper() == strDestinationFolderPath.Trim().ToUpper()) { MessageBox.Show("Selected file is destination path.\nPlease select another source path.", J_Var.J_pProjectName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); BtnBrowser.Select(); return; } if (File.Exists(strDestinationFolderPath + "/" + J_Var.J_pExeFileName + ".exe") == true) { File.Copy(strDestinationFolderPath + "/" + J_Var.J_pExeFileName + ".exe", strDestinationFolderPath + "/" + string.Format("{0:yyyyMMdd}", System.DateTime.Now.Date) + string.Format("{0:HHmmss}", System.DateTime.Now) + "-" + J_Var.J_pExeFileName + ".exe", true); File.Delete(strDestinationFolderPath + "/" + J_Var.J_pExeFileName + ".exe"); } File.Copy(strSourceFilePath, strDestinationFolderPath + "/" + J_Var.J_pExeFileName + ".exe"); if (MessageBox.Show("Want to proceed....", J_Var.J_pProjectName, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No) { return; } MessageBox.Show("Application successfully updated", J_Var.J_pProjectName, MessageBoxButtons.OK, MessageBoxIcon.Information); if (File.Exists(strDestinationFolderPath + "/" + J_Var.J_pExeFileName + ".exe") == true) { this.Close(); this.Dispose(); Process.Start(strDestinationFolderPath + "/" + J_Var.J_pExeFileName + ".exe"); } }
private void SysServerInfoLocalBrowser_Load(object sender, EventArgs e) { txtBrowser.Text = ""; BtnBrowser.Select(); }