コード例 #1
0
ファイル: Arquivo.xaml.cs プロジェクト: shadowgates/Aula-CS
        private void AbrirArquivoOk(object sender, System.ComponentModel.CancelEventArgs e)
        {
            try
            {
                caminho = DialogoAbrir.FileName;

                NomeArquivo.Text = DialogoAbrir.FileName;
                FileInfo arquivo = new FileInfo(DialogoAbrir.FileName);
                Conteudo.Text = "";

                TextReader reader = null;
                reader = arquivo.OpenText();

                string line = reader.ReadLine();
                while (line != null)
                {
                    Conteudo.Text += line + "\n";
                    line           = reader.ReadLine();
                }
                reader.Close();
                flag             = false;
                Salvar.IsEnabled = false;

                throw new System.ArgumentException("Teste", "original");
            }
            catch (Exception ex)
            {
                AppManager.AppExceptionsTxt exc = new AppExceptionsTxt();
                exc.SalvarExcecao(ex);
            }
        }
コード例 #2
0
ファイル: Arquivo.xaml.cs プロジェクト: shadowgates/Aula-CS
 protected void SalvarArquivo()
 {
     try
     {
         if (caminho.Trim() == "")
         {
             DialogoSalvar.ShowDialog();
         }
         else
         {
             File.WriteAllText(caminho, Conteudo.Text, Encoding.UTF8);
             flag                 = false;
             Salvar.IsEnabled     = false;
             SalvarComo.IsEnabled = false;
         }
     }
     catch (Exception ex)
     {
         AppManager.AppExceptionsTxt exc = new AppExceptionsTxt();
         exc.PathSaveException = "C:";
         exc.SalvarExcecao(ex, caminho);
     }
 }