Ejemplo n.º 1
0
        private void carregarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <string> comandos = new List <string>();

            using (var file = new OpenFileDialog())
            {
                file.Filter = "txt files (*.txt)|*.txt";

                DialogResult resultado = file.ShowDialog();

                if (resultado == DialogResult.OK && !string.IsNullOrWhiteSpace(file.FileName))
                {
                    Util.Saves save = new Util.Saves();

                    comandos = save.LerArquivo(file.FileName);
                }
                else if (resultado == DialogResult.Cancel)
                {
                    return;
                }
            }

            try
            {
                listComandos.Items.Clear();

                foreach (string comando in comandos)
                {
                    listComandos.Items.Add(comando);
                }
            }
            catch (Exception ex)
            {
                AlertaErro(ex.ToString());
            }
        }