Click here to Skip to main content
16,005,316 members
Home / Discussions / C#
   

C#

 
GeneralRe: Restoring a previous instance. Pin
mav.northwind30-Aug-04 22:21
mav.northwind30-Aug-04 22:21 
QuestionCrystal Report print? Pin
murali_utr30-Aug-04 9:01
murali_utr30-Aug-04 9:01 
QuestionHow to clear selected items from multiple checkedlistboxes Pin
abhishk2001@yahoo.com30-Aug-04 8:40
abhishk2001@yahoo.com30-Aug-04 8:40 
AnswerRe: How to clear selected items from multiple checkedlistboxes Pin
Nick Parker30-Aug-04 9:27
protectorNick Parker30-Aug-04 9:27 
AnswerRe: How to clear selected items from multiple checkedlistboxes Pin
Heath Stewart30-Aug-04 9:47
protectorHeath Stewart30-Aug-04 9:47 
GeneralRe: ISA bus access Pin
Dave Kreskowiak30-Aug-04 7:47
mveDave Kreskowiak30-Aug-04 7:47 
Generalget drive roots Pin
fire.fox30-Aug-04 7:36
fire.fox30-Aug-04 7:36 
GeneralRe: get drive roots Pin
Heath Stewart30-Aug-04 8:10
protectorHeath Stewart30-Aug-04 8:10 
.NET Framework 2.0 will add a new class, System.IO.DriveInfo, which can do this easily.

For now with .NET Framework 1.x, there are several ways. One is to use WMI with the System.Management namespace like so:
using System;
using System.Management;

class Test
{
  static void Main(string[] args)
  {
    ManagementObjectSearcher searcher =
      new ManagementObjectSearcher("select * from Win32_LogicalDisk");
    ManagementObjectCollection objects = searcher.Get();
    if (objects != null)
    {
      foreach (ManagementObject obj in objects)
        Console.WriteLine(obj.Properties["DeviceID"].Value);
    }
  }
}
You could also P/Invoke several native APIs, like GetLogicalDrives:
using System;
using System.Collections;
using System.Runtime.InteropServices;

class Test
{
  static void Main(string[] args)
  {
    uint drives = GetLogicalDrives();
    byte[] buffer = BitConverter.GetBytes(drives);
    BitArray bits = new BitArray(buffer);
    for (int i=0, j=65; i<bits.Count; i++, j++)
      if (bits[i])
        Console.WriteLine((char)j + ":");
  }

  [DllImport("kernel32.dll", SetLastError=true)]
  static extern uint GetLogicalDrives();
}
There's many ways, but I hope these two alternatives for .NET 1.x point you in the right direction.

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles]
GeneralRe: get drive roots Pin
leppie30-Aug-04 22:23
leppie30-Aug-04 22:23 
GeneralRe: get drive roots Pin
Heath Stewart31-Aug-04 6:15
protectorHeath Stewart31-Aug-04 6:15 
Generalpopulate treeview with dataset Pin
Anonymous30-Aug-04 7:01
Anonymous30-Aug-04 7:01 
GeneralRe: populate treeview with dataset Pin
Heath Stewart30-Aug-04 7:49
protectorHeath Stewart30-Aug-04 7:49 
QuestionCan apple ArrayList in string[] Pin
arbrsoft30-Aug-04 6:57
arbrsoft30-Aug-04 6:57 
AnswerRe: Can apple ArrayList in string[] Pin
Judah Gabriel Himango30-Aug-04 7:02
sponsorJudah Gabriel Himango30-Aug-04 7:02 
GeneralNested UserControls Pin
Den2Fly30-Aug-04 6:16
Den2Fly30-Aug-04 6:16 
GeneralRe: Nested UserControls Pin
Charlie Williams30-Aug-04 6:24
Charlie Williams30-Aug-04 6:24 
GeneralRe: Nested UserControls Pin
Nick Parker30-Aug-04 6:25
protectorNick Parker30-Aug-04 6:25 
QuestionHas anyone attempted synchronized scolling? Pin
LongRange.Shooter30-Aug-04 6:12
LongRange.Shooter30-Aug-04 6:12 
AnswerRe: Has anyone attempted synchronized scolling? Pin
Heath Stewart30-Aug-04 7:34
protectorHeath Stewart30-Aug-04 7:34 
GeneralRe: Has anyone attempted synchronized scolling? Pin
LongRange.Shooter31-Aug-04 6:50
LongRange.Shooter31-Aug-04 6:50 
GeneralRe: Has anyone attempted synchronized scolling? Pin
progload3-Oct-04 10:21
progload3-Oct-04 10:21 
GeneralErrorProvider() Not Displayed Pin
dbetting30-Aug-04 5:36
dbetting30-Aug-04 5:36 
Generalinstalling global cbt hooks in c# Pin
vignesh_s30-Aug-04 3:51
vignesh_s30-Aug-04 3:51 
GeneralRe: installing global cbt hooks in c# Pin
Nick Parker30-Aug-04 4:15
protectorNick Parker30-Aug-04 4:15 
GeneralRe: installing global cbt hooks in c# Pin
Duncan Edwards Jones30-Aug-04 4:15
professionalDuncan Edwards Jones30-Aug-04 4:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.