Created
July 14, 2015 23:45
-
-
Save Fhernd/8dd61c39ff967daf8e2e to your computer and use it in GitHub Desktop.
Programa basado en consola para la búsqueda de archivos con comodín.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// OrtizOL - xCSw - http://ortizol.blogspot.com | |
using System; | |
using System.IO; | |
namespace Receta.CSharp.R0510 | |
{ | |
public class BusquedaConComodin | |
{ | |
public static void Main(string[] args) | |
{ | |
Console.WriteLine(Environment.NewLine); | |
// Valida que el usuario haya ingresado | |
// el número apropiado de argumentos: | |
if (args.Length != 2) | |
{ | |
Console.WriteLine("Uso: BusquedaConComodin.exe [directorio] [comodin]"); | |
} | |
// Creación de instancia de `DirectoryInfo`: | |
DirectoryInfo dir = new DirectoryInfo(args[0]); | |
// Arreglo de todos los archivos del directorio: | |
FileInfo[] archivos = dir.GetFiles(args[1]); | |
// Muestra los archivos que coinciden con el | |
// comodín pasado como argumento: | |
foreach (FileInfo archivo in archivos) | |
{ | |
Console.Write("Archivo: {0} - Tamaño: {1}\n", archivo.Name, archivo.Length.ToString()); | |
} | |
Console.WriteLine(Environment.NewLine); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment