コード例 #1
0
ファイル: Program.cs プロジェクト: TrittoG/Programacion-II
        static void Main(string[] args)
        {
            Console.Title = "Ejercicio Nro42";
            StringBuilder path = new StringBuilder();

            path.AppendFormat("{0}{1}{2}-{3}{4}.txt", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute);
            try
            {
                Class2 b = new Class2();
            }
            catch (UnaException ex)
            {
                if (ex.InnerException != null)
                {
                    ArchivoTexto.Guardar(path.ToString(), ex.Message + ", " + ex.InnerException.Message);
                }
                else
                {
                    ArchivoTexto.Guardar(path.ToString(), ex.Message);
                }
            }
            catch (DivideByZeroException ex)
            {
                ArchivoTexto.Guardar(path.ToString(), ex.Message);
            }
            catch (Exception ex)
            {
                ArchivoTexto.Guardar(path.ToString(), ex.Message);
            }

            Console.WriteLine(ArchivoTexto.Leer(path.ToString()));
            Console.ReadKey();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: TrittoG/Programacion-II
        static void Main(string[] args)
        {
            Console.Title = "Ejercicio Nro42";
            DateTime hoy = new DateTime();

            hoy = DateTime.Now;

            try
            {
                Class2 b = new Class2();
            }
            catch (UnaException ex)
            {
                if (ex.InnerException != null)
                {
                    //Console.WriteLine(ex.Message + ", " + ex.InnerException.Message);
                    ArchivoTexto.Guardar("archivo.txt", ex.Message + " " + ex.InnerException.Message + hoy.Date.ToString());
                }

                else
                {
                    //Console.WriteLine(ex.Message);
                    ArchivoTexto.Guardar("archivo.txt", ex.Message + hoy.Date.ToString());
                }
            }
            catch (DivideByZeroException ex)
            {
                //Console.WriteLine(ex.Message);
                ArchivoTexto.Guardar("archivo.txt", ex.Message + hoy.Date.ToString());
            }
            catch (Exception ex)
            {
                //Console.WriteLine(ex.Message);
                ArchivoTexto.Guardar("archivo.txt", ex.Message + hoy.Date.ToString());
            }

            Console.WriteLine(ArchivoTexto.Leer("archivo.txt"));
            Console.ReadKey();
        }