Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Getting Disk Drives

Getting Disk Drives

Scheduled Pinned Locked Moved C#
question
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vertyg0
    wrote on last edited by
    #1

    I`m using System.IO.DriveInfo.GetDrives() funcd tion to get DriveInfo anextract information about drives but it works really bad with SATA disks (gives me errors)? Does anybody have solution for this?

    N 1 Reply Last reply
    0
    • V Vertyg0

      I`m using System.IO.DriveInfo.GetDrives() funcd tion to get DriveInfo anextract information about drives but it works really bad with SATA disks (gives me errors)? Does anybody have solution for this?

      N Offline
      N Offline
      Nader Elshehabi
      wrote on last edited by
      #2

      Vertyg0 wrote:

      but it works really bad with SATA disks (gives me errors)

      What are the errors you get exactly? Also a code snippet would be very helpful.

      Regards:rose:

      V 1 Reply Last reply
      0
      • N Nader Elshehabi

        Vertyg0 wrote:

        but it works really bad with SATA disks (gives me errors)

        What are the errors you get exactly? Also a code snippet would be very helpful.

        Regards:rose:

        V Offline
        V Offline
        Vertyg0
        wrote on last edited by
        #3

        DriveInfo[] drivesInfo = DriveInfo.GetDrives(); foreach (DriveInfo drive in drivesInfo) listBox1.Items.Add(drive.Name + " " + drive.VolumeLabel); ************** Exception Text ************** System.IO.IOException: The device is not ready. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.__Error.WinIODriveError(String driveName, Int32 errorCode) at System.IO.DriveInfo.get_VolumeLabel() at SqlServerMonitor.AddDisk.AddDisk_Load(Object sender, EventArgs e) in C:\...\AddDisk.cs:line 23 at System.Windows.Forms.Form.OnLoad(EventArgs e) at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ContainerControl.WndProc(Message& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

        W 1 Reply Last reply
        0
        • V Vertyg0

          DriveInfo[] drivesInfo = DriveInfo.GetDrives(); foreach (DriveInfo drive in drivesInfo) listBox1.Items.Add(drive.Name + " " + drive.VolumeLabel); ************** Exception Text ************** System.IO.IOException: The device is not ready. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.__Error.WinIODriveError(String driveName, Int32 errorCode) at System.IO.DriveInfo.get_VolumeLabel() at SqlServerMonitor.AddDisk.AddDisk_Load(Object sender, EventArgs e) in C:\...\AddDisk.cs:line 23 at System.Windows.Forms.Form.OnLoad(EventArgs e) at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ContainerControl.WndProc(Message& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

          W Offline
          W Offline
          Weckmann
          wrote on last edited by
          #4

          I would put the listBox1.Items.Add... in a try/catch , because you probably are asking your DVD-drive to tell you the VolumeLabel and if there is no DVD in it you will get an exception.

          -------------------- Bertram Weckmann www.svizzer.com --------------------

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups