Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created July 4, 2015 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fhernd/556c0537c426fd58b7a7 to your computer and use it in GitHub Desktop.
Save Fhernd/556c0537c426fd58b7a7 to your computer and use it in GitHub Desktop.
Uso de la clase `FileInfo` en C#.
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