Pages

Friday, August 28, 2009

Get System Drives C# by Praveen P.R

// Code in C#

//Get System Drives
public static void getSystemDrives(ComboBox cmbBox)
  {
  DriveInfo[] allDrives = DriveInfo.GetDrives();

  foreach (DriveInfo d in allDrives)
  {
  if (d.IsReady)
  {
  cmbBox.Items.Add((object)d.Name);
  }
  }
  if (cmbBox.Items.Count > 0)
  {
  cmbBox.SelectedIndex = 0;
  }
  }

No comments: