Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created July 19, 2015 01:33
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/703c6bea1132c5c45a24 to your computer and use it in GitHub Desktop.
Save Fhernd/703c6bea1132c5c45a24 to your computer and use it in GitHub Desktop.
Muestra el espacio libre disponible de unidad de disco.
// OrtizOL - xCSw - http://ortizol.blogspot.com
using System;
using System.IO;
namespace Receta.CSharp.R0516
{
public class InformacionUnidad
{
public static void Main(string[] args)
{
Console.WriteLine(Environment.NewLine);
// Valida la entrada del usuario:
if (args.Length == 1)
{
DriveInfo unidad = new DriveInfo(args[0]);
Console.WriteLine ("Espacio disponible en la unidad {0}: {1} KB",
args[0], unidad.AvailableFreeSpace / 1024);
Console.ReadLine();
return;
}
foreach(DriveInfo unidad in DriveInfo.GetDrives())
{
try
{
Console.WriteLine ("Espacio disponible en la unidad {0}: {1} KB",
unidad.RootDirectory, unidad.AvailableFreeSpace / 1024);
}
catch (IOException) // Es posible que unidad de red no esté disponible
{
Console.WriteLine("[Advertencia]: La unidad {0} no está disponible.", unidad);
}
}
Console.WriteLine(Environment.NewLine);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment