---
title: "How do I detect a USB drive letter from a c# application?"  
description: "How do I detect a USB drive letter from a c# application?"  
author: "Anonymous User"  
published: 2013-10-16  
updated: 2013-10-16  
canonical: https://www.mindstick.com/forum/1692/how-do-i-detect-a-usb-drive-letter-from-a-c-sharp-application  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# How do I detect a USB drive letter from a c# application?

How to [detect](https://www.mindstick.com/forum/1906/detect-when-cd-drive-was-closed) the [USB](https://www.mindstick.com/articles/13074/what-makes-usb-c-cables-better-than-other-usb-cables) drive letter from [c# program](https://www.mindstick.com/forum/156830/how-do-i-make-a-c-sharp-program-that-checks-for-given-array-by-user-which-elements-are-perfect-numbers) which is not residing in the USB?

## Replies

### Reply by Anonymous User

Below line of code will get all of the removable drives attached (including USB drives):

```
foreach (DriveInfo driveInfo in DriveInfo.GetDrives())
{
    if (driveInfo.DriveType == DriveType.Removable)
    {
        // Code here
    }
}
```


---

Original Source: https://www.mindstick.com/forum/1692/how-do-i-detect-a-usb-drive-letter-from-a-c-sharp-application

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
