public Updater() { inputSetting = (Settings)xobj; //Kill the process Process[] processes = Process.GetProcessesByName("SummaryToolForm"); if (processes.Length > 0) processes[0].Kill(); // Get current time zone. TimeZone zone = TimeZone.CurrentTimeZone; string standard = zone.StandardName; ServerDir = inputSetting.ITCDirectory; if (standard != "India Standard Time") { ServerDir = inputSetting.AustinDirectory; } string LocalDir = System.IO.Directory.GetCurrentDirectory(); //Check the program is running as updater or Installer if (System.IO.Path.GetFileNameWithoutExtension(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName) == "Update") { //Skip the development copy if (!System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName).Contains("bin\\Debug")) CopyDir(ServerDir, LocalDir); } else //runs as installer { InstallerForm f = new InstallerForm(FolderStructure + Production + "\\Summary Tool.exe"); LocalDir = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),"Summary Tool"); if (!System.IO.Directory.Exists(LocalDir)) System.IO.Directory.CreateDirectory(LocalDir); DirectoryCopy(ServerDir, LocalDir); appShortcutToDesktop("test"); //***cb******* } }
public Updater() { inputSetting = (Settings)xobj; //Kill the process Process[] processes = Process.GetProcessesByName("SummaryToolForm"); if (processes.Length > 0) processes[0].Kill(); // Get current time zone. TimeZone zone = TimeZone.CurrentTimeZone; string standard = zone.StandardName; ServerDir = inputSetting.ITCDirectory; if (standard != "India Standard Time") { ServerDir = inputSetting.AustinDirectory; } string Base = System.Reflection.Assembly.GetExecutingAssembly().CodeBase; string LocalDir = System.IO.Path.GetDirectoryName(Base).Replace("file:\\", ""); //Copies the files from server InstallerForm f = new InstallerForm(FolderStructure + Production + "\\SummaryToolForm.exe"); //Check the program is running as updater or Installer if (System.IO.Path.GetFileNameWithoutExtension(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName) == "Update") { //Skip the development copy if (!System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName).Contains("bin\\Debug")) { //DirectoryCopy(ServerDir, LocalDir,true,true); MessageBox.Show("Updated Successfully.!"); //To get the location the assembly normally resides on disk or the install directory Base = System.Reflection.Assembly.GetExecutingAssembly().CodeBase; LocalDir = System.IO.Path.GetDirectoryName(Base).Replace("file:\\", ""); System.Diagnostics.Process.Start(System.IO.Path.Combine(LocalDir, "SummaryToolForm.exe")); } } else //runs as installer { MessageBox.Show("Installed, use the shortcut created in your desktop (Ctrl+Alt+C)!"); } }