Exemple #1
0
        static void Main(string[] args)
        {
            ArchivoTexto a = new ArchivoTexto();

            try
            {
                OtraClase x = new OtraClase();
                x.MetodoDeInstancia();
            }catch (Exception ex)
            {
                Console.WriteLine(ex.Message);

                Exception e = ex.InnerException;
                while (!object.ReferenceEquals(e, null))
                {
                    //Console.WriteLine(e.Message);//voy imprimiendo todas las excepciones ya entendi
                    a.Guardar(AppDomain.CurrentDomain.BaseDirectory + (DateTime.Now.Year).ToString() + (DateTime.Now.Month).ToString() + (DateTime.Now.Day).ToString() + "-" + DateTime.Now.Hour.ToString() + DateTime.Now.Hour.ToString() + ".txt", e.Message);
                    e = e.InnerException;
                }
            }


            Console.WriteLine(a.Leer(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + (DateTime.Now.Year).ToString() + (DateTime.Now.Month).ToString() + (DateTime.Now.Day).ToString() + "-" + DateTime.Now.Hour.ToString() + DateTime.Now.Hour.ToString() + ".txt"));

            //se rompe
            Console.ReadKey();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            OtraClase otraClase;

            try
            {
                otraClase = new OtraClase();
                otraClase.MetodoDeInstancia();
            }
            catch (MiExcepcion e)
            {
                Console.WriteLine(e.Message);

                if (!(e.InnerException is null))
                {
                    Exception auxException = e.InnerException;

                    do
                    {
                        Console.WriteLine(auxException.Message);
                        auxException = auxException.InnerException;
                    } while (!(auxException is null));
                }
            }
            Console.ReadKey();
        }
Exemple #3
0
        static void Main(string[] args)
        {
            try
            {
                OtraClase x = new OtraClase();
                x.MetodoDeInstancia();
            }catch (Exception ex)
            {
                Console.WriteLine(ex.Message);

                //if(!object.ReferenceEquals(ex.InnerException,null))
                //{
                Exception e = ex.InnerException;
                while (!object.ReferenceEquals(e, null))
                {
                    Console.WriteLine(e.Message);    //voy imprimiendo todas las excepciones ya entendi
                    e = e.InnerException;
                }
                //}
            }

            Console.ReadKey();
        }