Advertisement
tolikpunkoff

Get all drives

Jul 27th, 2021
1,828
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.41 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.IO;
  5.  
  6. namespace tmpGetAllDrives
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             Console.WriteLine("List of drives:");
  13.             DriveInfo[] Drives = DriveInfo.GetDrives();
  14.  
  15.             foreach (DriveInfo drive in Drives)
  16.             {
  17.                 Console.WriteLine("Drive: {0}", drive.Name); //имя диска
  18.                 Console.WriteLine("Drive format: {0}", drive.DriveFormat); //файловая система
  19.                 Console.WriteLine("Drive type: {0}", drive.DriveType); // Тип диска
  20.                 Console.WriteLine("Drive root: {0}", drive.RootDirectory); //Корневой каталог
  21.                 Console.WriteLine("Drive label: {0}", drive.VolumeLabel); //Метка тома
  22.                 Console.WriteLine("Drive free space: {0}", drive.TotalFreeSpace); //Свободное место (байт)
  23.                 Console.WriteLine("Drive total size: {0}", drive.TotalSize); //Размер (байт)
  24.                 Console.WriteLine("Drive ready status: {0}", drive.IsReady); //Готовность диска
  25.                 Console.WriteLine("==============================================");                
  26.             }
  27.            
  28.             Console.WriteLine("Press Enter...");
  29.             Console.ReadLine();
  30.         }
  31.     }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement