Ejemplo n.º 1
0
        private static void Main()
        {
            Console.Title = @"Comet";

            ConsoleManager.DrawLine();
            Console.WriteLine(@"Comet Installer");

            try
            {
                _resourceSettings = new ResourceSettings();
                TerminateRunningProcess(_resourceSettings);
                Installer.InstallData(_resourceSettings);

                if (_resourceSettings.RestartApplicationAfterInstall)
                {
                    StartExecutable(_resourceSettings.ExecutablePath);
                }
                else
                {
                    // TODO: Exit
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Terminate the running process.
        /// </summary>
        /// <param name="resourceSettings">The resource settings.</param>
        private static void TerminateRunningProcess(ResourceSettings resourceSettings)
        {
            string _processName = Path.GetFileNameWithoutExtension(resourceSettings.ExecutablePath);

            foreach (Process _process in Process.GetProcesses())
            {
                if (_process.ProcessName == _processName)
                {
                    Console.WriteLine(@"Terminating process: " + _processName);
                    ConsoleManager.DrawLine();
                    _process.Kill();
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>Cleanup the temporary install files.</summary>
        /// <param name="resourceSettings">The resource Settings.</param>
        public static void Cleanup(ResourceSettings resourceSettings)
        {
            Console.WriteLine(@"Cleaning up...");
            ConsoleManager.DrawLine();

            if (Directory.Exists(resourceSettings.DownloadFolder))
            {
                Directory.Delete(resourceSettings.DownloadFolder, true);
            }

            if (Directory.Exists(resourceSettings.InstallFilesFolder))
            {
                Directory.Delete(resourceSettings.InstallFilesFolder, true);
            }
        }
Ejemplo n.º 4
0
        /// <summary>Install the data.</summary>
        /// <param name="resourceSettings">The resource Settings.</param>
        public static void InstallData(ResourceSettings resourceSettings)
        {
            Console.WriteLine(@"Installing...");
            ConsoleManager.DrawLine();

            foreach (string _file in Directory.GetFiles(resourceSettings.InstallFilesFolder, "*.*", SearchOption.AllDirectories))
            {
                string _destination = _file.Replace(resourceSettings.InstallFilesFolder, resourceSettings.InstallDirectory);

                Console.WriteLine(@"Copying file: " + _file);
                Console.WriteLine(@"To: " + _destination);
                ConsoleManager.DrawLine();
                File.Copy(_file, _destination, true);
            }

            Cleanup(resourceSettings);
        }