Created
July 19, 2015 01:33
-
-
Save Fhernd/703c6bea1132c5c45a24 to your computer and use it in GitHub Desktop.
Muestra el espacio libre disponible de unidad de disco.
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.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