Flg. burde kunne klare dit problem:
using System;
using System.IO;
using System.Management;
namespace GetDrives
{
class MainClass
{
static void PrintDrives()
{
string[] Drives = Directory.GetLogicalDrives();
foreach(string Drive in Drives)
{
string TmpDrive = Drive.TrimEnd('\\\\');
ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\\"" + TmpDrive + "\\"");
string Type = "";
switch(disk["DriveType"].ToString())
{
case "0": Type = "Error getting drive type!"; break;
case "1": Type = "No such drive!"; break;
case "2": Type = "Floppy"; break;
case "3": Type = "Harddrive"; break;
case "4": Type = "Net-drive"; break;
case "5": Type = "CD-ROM"; break;
case "6": Type = "RAM-drive"; break;
}
Console.WriteLine(Drive.ToString() + " - " + Type);
}
}
public static void Main(string[] args)
{
PrintDrives();
}
}
}
MH.
The-Freak
Livet er for kort til at kede sig.