How to use the DriveInfo class in C#

Category > CSHARP || Published on : Sunday, September 27, 2020 || Views: 198 || DriveInfo class in C#


Here Pawan Kumar will explain How to use the DriveInfo class in C#

using System;
using System.IO;
namespace Demo
{
class Program
{
// The main function
static void Main(string[] args)
{
DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in allDrives)
{
Console.WriteLine("Drive {0}", d.Name);
Console.WriteLine(" Drive type: {0}", d.DriveType);
}
Console.Read();
}
}
}