---
title: "Get list of logical drives information using C#"  
description: "In this article I am making a small demo application for getting the logical  drives information using C#. Here I create DriveInfoinstanceto get list"  
author: "Vijay Shukla"  
published: 2013-10-10  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/1377/get-list-of-logical-drives-information-using-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# Get list of logical drives information using C#

## Get list of logical drives information using C#

In this article I am making a small demo [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) for getting the logical drives information using C#. Here I create **[DriveInfo](https://www.mindstick.com/forum/161631/how-do-you-use-driveinfo-to-get-information-about-available-drives-and-their-free-space)**[instance](https://www.mindstick.com/forum/155658/testing-connection-to-cloud-sql-instance-with-a-mysql-client-from-vm-instance) to get list of [capacity](https://www.mindstick.com/interview/832/what-is-the-difference-between-the-size-and-capacity-of-a-vector) of drive, used size of drive, free drive size and file type of logical drives.

## Getting Start: -

1. Create a console [project in visual](https://www.mindstick.com/forum/537/how-to-add-a-custom-icon-to-setup-project-in-visual-studio-2010) studio with appropriate name.

2. In the Main() write the below line of code for getting the logical drives information.

DriveInfo[] drives = DriveInfo.GetDrives();// Create DriveInfo Type [variable](https://www.mindstick.com/blog/11493/what-is-a-variable) and get the all information of drives with the help of DriveInfo.GetDrives() method.

Console.WriteLine("=================================");

Console.WriteLine("\tProperties");

Console.WriteLine("=================================");

foreach (DriveInfo drive in drives)

{

Console.WriteLine("=================================");

Console.WriteLine("\tProperties");

Console.WriteLine("=================================");

Console.WriteLine("Drive: {0}", drive.Name); // Show drive name

if (drive.TotalSize > 1073741824) //check the drive is MB or GB

Console.WriteLine("Used Space: {0}GB", (drive.TotalSize / 1073741824) - (drive.AvailableFreeSpace / 1073741824)); // Shows Used drive space in GB if [total size](https://www.mindstick.com/interview/34111/how-do-you-calculate-the-total-size-of-all-files-in-a-directory-including-subdirectories) in GB

else

Console.WriteLine("Used Space: {0}MB", (drive.TotalSize / 1073741824) - (drive.AvailableFreeSpace / 1073741824)); // Shows Used drive space in MB if total size in MB

if (drive.AvailableFreeSpace > 1073741824)

Console.WriteLine("Space Reamining:{0}GB", drive.AvailableFreeSpace / 1073741824); // Shows available drive space in MB if total size in GB

else

Console.WriteLine("Space Reamining:{0}MB", drive.AvailableFreeSpace / 1073741824); // Shows available drive space in MB if total size in MB

if (drive.TotalSize > 1073741824)

Console.WriteLine("Capacity:{0}GB", drive.TotalSize / 1073741824); // Shows Total drive space in MB if total size in GB

else

Console.WriteLine("Capacity:{0}MB", drive.TotalSize / 1073741824); // Shows Total drive space in MB if total size in MB

Console.WriteLine("[File System](https://www.mindstick.com/forum/157850/what-is-a-file-system-explain-it-s-used-in-system-software): {0}", drive.DriveFormat); // Shows Total drive File System

}

Console.ReadKey();

***Note :-*** *copy the above line of code and paste into your main folder and run your demo project.*

## Output: -

![Get list of logical drives information using C#](https://www.mindstick.com/mindstickarticle/1b20c329-8050-4c98-b30f-f6e27fb053bd/images/023da147-7ee4-4dde-905f-d88d708536fb.png)

---

Original Source: https://www.mindstick.com/articles/1377/get-list-of-logical-drives-information-using-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
