/// <summary> /// Carrega as informações do xml /// </summary> /// <returns>Retorna o arquivo de configuração</returns> public static ConfiguracoesXml CarregarConfiguracao() { if (!Directory.Exists(Folder)) //Se o diretório não existir... { //Criamos um com o nome folder Directory.CreateDirectory(Folder); } string path = string.Format("{0}/{1}/{2}", Environment.CurrentDirectory, Folder, File); StreamReader sR = null; try { XmlSerializer serializer = new XmlSerializer(typeof(ConfiguracoesXml)); sR = new StreamReader(path); ConfiguracoesXml config = (ConfiguracoesXml)serializer.Deserialize(sR); sR.Close(); return(config); } catch (Exception) { if (sR != null) { sR.Close(); } ConfiguracoesXml nova = new ConfiguracoesXml(); nova.GravarConfiguracao(); return(nova); } }
public Atualizador(string argumento) { Console.WriteLine("Carregando configurações do sistema."); try { Configuracoes = ConfiguracoesXml.CarregarConfiguracao().ToModel(); Argumento = argumento; Arquivos = new List <FileInfo>(); ArquivosNovos = new List <FileInfo>(); Processo = new Process(); } catch (Exception e) { while (e.InnerException != null) { e = e.InnerException; } MessageBox.Show("Não foi possível iniciar a atualização", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); Logs.Error(e.Message); Environment.Exit(0); } finally { Task.Run(() => Start()).Wait(); } }