0 Replies - 193 Views - Last Post: 12 June 2008 - 04:36 PM

#1 aj32   User is offline

  • D.I.C Addict
  • member icon

Reputation: 33
  • View blog
  • Posts: 577
  • Joined: 30-August 07

Get a list of drives installed on the machine

Posted 12 June 2008 - 04:36 PM

Description: 1. Place this code in a class
2. See the "// Example Usage //" for info on how to use it.This will get a list of installed drives (and partitions) on the computer.
/// <summary>
/// Get's a list of drives installed on the computer
/// </summary>
/// <returns></returns>
private System.Collections.ArrayList getdrives()
{
    System.Collections.ArrayList DriveArray = new System.Collections.ArrayList();
    DriveArray.AddRange(System.IO.DriveInfo.GetDrives().ToArray());

    return DriveArray;
}


//  Example Usage //
string drives = null;

for (int i = 0; i < getdrives().Count; i++)
    drives += getdrives()[i];

MessageBox.Show("There are " + getdrives().Count + " drives installed: " + drives);


// END //


Is This A Good Question/Topic? 0
  • +

Page 1 of 1