//definicion metodo comprar
 public void comprar()
 {
     if (Suma <= 500)
     {
         Print.BluePrint("Gracias por su compra");
     }
     else
     {
         Print.RedPrint("Dinero insuficiente deje productos");
         dejarproductos();
     }
 }
        //Eliminar Usuarios
        static void eliminar()
        {
            //leemos el nombre
            string nombre = Read.ReadString("Ingrese el nombre para eliminar");

            /* VALIDACION:
             * Verificamos que el nombre que queremos eliminar exista*/
            if (!dic.Remove(nombre))
            {
                Print.RedPrint("El nombre no existe en la agenda");
                return;
            }
            //Confirammos que eliminamos al usuario
            Print.BluePrint("Contacto Eliminado");
        }
////////////////////////////////////////////////////////////////////////////////

        //Agregar Usuarios
        static void agregar()
        {
            //Leemos el nombre
            string nombre = Read.ReadString("Ingrese el nombre para agregar: ");

            /* VALIDACION:
             * Verificamos que el nombre que queremos agregar no exista*/
            if (dic.ContainsKey(nombre))
            {
                Print.RedPrint(
                    "Error el nombre ya existe",
                    "Contacto no agregado");
                return;
            }
            //Agregamos el numero al diccionario, con el nombre
            dic[nombre] = Read.ReadInt("Ingrese el numero para agregar: ");
            //Confirmamos que agregamos el usuario
            Print.BluePrint("Contacto Agregado");
        }
示例#4
0
        /// <summary>
        /// Crea un directorio de acuerdo a la ruta especificada
        /// </summary>
        /// <param name="path"></param>
        /// <param name="directory"></param>
        public static void touch_file(string path, string directory)
        {
            string currentfile = Path.GetFullPath(directory, path);

            try{
                FileStream fs = File.Create(currentfile);
                if (File.Exists(currentfile))
                {
                    throw new FileExistsException();
                }
            }catch (UnauthorizedAccessException e) {
                Console.WriteLine(e.Message);
                Print.RedPrint("No tienes los permisos");
            }catch (DirectoryNotFoundException) {
                Print.RedPrint("No se ha encontrado el directorio especificado");
            }catch (IOException e) {
                Print.RedPrint(e.Message);
            }catch (FileExistsException) {
                Print.BluePrint("El archivo se sobreescribio");
            }
        }
示例#5
0
        /// <summary>
        /// Para este ejercicio el directorio por defecto será mis Documentos
        /// </summary>
        //public static string CurrentPath { get; set; } = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

        /// <summary>
        /// Muetra los subdirectorios
        /// </summary>
        /// <param name="path">El directorio base del que tomaremos los subdirectorios</param>
        public static void show_directories(string path)
        {
            try{
                Print.BluePrint("DIRECTORIOS:");
                foreach (string dir in Directory.GetDirectories(path, "*", SearchOption.TopDirectoryOnly))
                {
                    Console.WriteLine(Path.GetRelativePath(path, dir));
                }
                Print.BluePrint("ARCHIVOS:");
                foreach (string file in Directory.GetFiles(path))
                {
                    Console.WriteLine(Path.GetRelativePath(path, file));
                }
            }catch (DirectoryNotFoundException) {
                Print.RedPrint("Directorio no encontrado");
            }catch (UnauthorizedAccessException e) {
                Console.WriteLine(e.Message);
                Print.RedPrint("No tienes los permisos para ver el directorio");
            }catch (IOException) {
                Print.RedPrint("La ruta debe ser un directorio no un archivo");
            }
        }