Sólo como referencia para cualquier otra persona, esto es lo que me di la respuesta de GenericTypeTea en:
/// <summary>
/// Gets the drive type of the given path.
/// </summary>
/// <param name="path">The path.</param>
/// <returns>DriveType of path</returns>
public static DriveType GetPathDriveType(string path)
{
//OK, so UNC paths aren't 'drives', but this is still handy
if(path.StartsWith(@"\\")) return DriveType.Network;
var info =
DriveInfo.GetDrives()
Where(i => path.StartsWith(i.Name, StringComparison.OrdinalIgnoreCase))
FirstOrDefault();
if(info == null) return DriveType.Unknown;
return info.DriveType;
}
(Es posible que desee también tomar nota de AJ Bauer's answer: DriveInfo también mostrará USB HD como DriveType.fixed)
"El título lo dice todo" - no, doesn; t. ¿En qué idioma/SO estás? ¿Necesita detectar una unidad USB conectada, etc. etc – Jamiec
@Jamiec - Creo que en este caso sí lo hizo. Mire sus etiquetas: C#, significa que está usando C# .Net, .Net significa que está usando Windows (muy probablemente), y su título de pregunta claramente indica que quiere saber qué tipo de unidad es una letra de unidad. De todos modos, edité la pregunta. – GenericTypeTea
@Jamiec, la pregunta 'detectar USB drive enchufado' ya ha sido aplastada hasta la muerte aquí en SO;) – Benjol