Autor Beitrag
Metrik
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 80

Win XP, Win Vista
C# (VS 2003, #Develop)
BeitragVerfasst: Do 22.12.05 21:52 
Hallo

Habe noch einemal eine (simple) Frage.
Wie kann ich ine ine Console (C#) die Lokalen Festplaten ermitteln.
Die ermittelten Laufwerke sollte ich dann mit einer Console.WriteLine();
schreiben können.

Vielleicht mit DriveInfo.GetDrives(); oder so ???


Metrik


Moderiert von user profile iconraziel: Topic aus C# - Die Sprache verschoben am Do 22.12.2005 um 21:00
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 22.12.05 22:46 
Hallo!

Das geht recht einfach:
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
      
using System.IO;

string[] drives = System.Environment.GetLogicalDrives();
foreach (string drive in drives)
{
  DriveInfo di = new DriveInfo(drive);
  if (di.DriveType == DriveType.Fixed)
      Console.WriteLine(drive);
}
Console.ReadLine();


Wie Du siehst, hast Du in drives die Namen aller Laufwerke. Über die DriveInfo kannst Du dann herausfinden, ob es sich um eine Festpplatte handelt.

Grüße
Christian

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Metrik Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 80

Win XP, Win Vista
C# (VS 2003, #Develop)
BeitragVerfasst: So 25.12.05 16:06 
Danke

Ganau das hab ich gebraucht!

Metrik