Created
July 4, 2015 22:49
-
-
Save Fhernd/556c0537c426fd58b7a7 to your computer and use it in GitHub Desktop.
Uso de la clase `FileInfo` en C#.
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
using System; | |
using System.IO; | |
namespace Receta.CSharp.R0501 | |
{ | |
public class UsoFileInfo | |
{ | |
public static void Main() | |
{ | |
Console.WriteLine (); | |
// Creación de una nueva instancia de FileInfo: | |
FileInfo archivoFuente = new FileInfo("UsoFileInfo.cs"); | |
// Confirma si el archivo existe: | |
if (archivoFuente.Exists) | |
{ | |
// Obtiene la hora de creación, la extensión, nombre completo, | |
// si es de sólo lectura, tamaño en bytes, y el nombre: | |
Console.WriteLine("Hora de creación: {0}", archivoFuente.CreationTime.ToString()); | |
Console.WriteLine("Extensión: {0}", archivoFuente.Extension.ToString()); | |
Console.WriteLine("Nombre completo: {0}", archivoFuente.FullName); | |
Console.WriteLine("¿Sólo lectura?: {0}", archivoFuente.IsReadOnly ? "Sí" : "No"); | |
Console.WriteLine("Tamaño en bytes: {0} bytes", archivoFuente.Length.ToString()); | |
Console.WriteLine("Nombre: {0}", archivoFuente.Name.ToString()); | |
} | |
else | |
{ | |
Console.WriteLine("El archivo `UsoFileInfo.cs` no existe."); | |
} | |
Console.WriteLine (); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment