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. Is there a way?

Is there a way?

Scheduled Pinned Locked Moved C#
question
5 Posts 5 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.
  • S Offline
    S Offline
    Silvyster
    wrote on last edited by
    #1

    is there a way to get all the root paths of all the drives? like c:\ d:\ e:\ f:\ and so on..

    S M L S 4 Replies Last reply
    0
    • S Silvyster

      is there a way to get all the root paths of all the drives? like c:\ d:\ e:\ f:\ and so on..

      S Offline
      S Offline
      SomeGuyThatIsMe
      wrote on last edited by
      #2

      WMI may help, but i dont know excatly how to do it. and there is probably a faster way, one of the guys here was using it to get the space used and space available on each drive on a system and remote server and it was kinda slow.

      Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

      1 Reply Last reply
      0
      • S Silvyster

        is there a way to get all the root paths of all the drives? like c:\ d:\ e:\ f:\ and so on..

        M Offline
        M Offline
        Manas Bhardwaj
        wrote on last edited by
        #3

        string[] drives = Environment.GetLogicalDrives();

        Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

        1 Reply Last reply
        0
        • S Silvyster

          is there a way to get all the root paths of all the drives? like c:\ d:\ e:\ f:\ and so on..

          L Offline
          L Offline
          lisan_al_ghaib
          wrote on last edited by
          #4

          Hello Yes ! you can use WMI to get all connected drives

          1 Reply Last reply
          0
          • S Silvyster

            is there a way to get all the root paths of all the drives? like c:\ d:\ e:\ f:\ and so on..

            S Offline
            S Offline
            Samer Aburabie
            wrote on last edited by
            #5

            Of course you can ... alot of ways to do so and WMI is one of them ... use the System.Management namespace to help you so ... as follows:

            ArrayList list = new ArrayList();
            using (ManagementObjectSearcher DiskSearch = new ManagementObjectSearcher(new SelectQuery("Select * from Win32_LogicalDisk")))
            {
            using (ManagementObjectCollection moDiskCollection = DiskSearch.Get())
            {
            foreach (ManagementObject mo in moDiskCollection)
            {
            list.Add(mo["Name"].ToString ());
            MessageBox.Show(mo["Name"].ToString());
            mo.Dispose();
            }
            }
            }

            Dont forget to add a reference in your project to System.Management dll and you will get all the drives .. for more properties go to this link to get them (other than the Name property used here): http://msdn.microsoft.com/en-us/library/aa394173.aspx[^] Enjoy ! Note: If you found this answer useful please indicate that so other would know so.

            Sincerely Samer Abu Rabie Software Engineer

            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