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. Visual Basic
  4. Hard drive Info

Hard drive Info

Scheduled Pinned Locked Moved Visual Basic
csharphelpquestion
8 Posts 2 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.
  • C Offline
    C Offline
    Code Crapper
    wrote on last edited by
    #1

    What would I type to get a computers Harddrive total space and used space? I have been looking around allot and all I have found is useless VB 6 code and some jibberish in C#, can someone please help me with this. Many Thanks :confused:

    O 1 Reply Last reply
    0
    • C Code Crapper

      What would I type to get a computers Harddrive total space and used space? I have been looking around allot and all I have found is useless VB 6 code and some jibberish in C#, can someone please help me with this. Many Thanks :confused:

      O Offline
      O Offline
      OldWarhorse
      wrote on last edited by
      #2

      System.IO.DriveInfo Boy, you're being a P.I.A. today. You're gonna owe me a cut of that app. :laugh:

      C 2 Replies Last reply
      0
      • O OldWarhorse

        System.IO.DriveInfo Boy, you're being a P.I.A. today. You're gonna owe me a cut of that app. :laugh:

        C Offline
        C Offline
        Code Crapper
        wrote on last edited by
        #3

        that easy!!! omg.. sorry for the dumb question :-D

        O 1 Reply Last reply
        0
        • C Code Crapper

          that easy!!! omg.. sorry for the dumb question :-D

          O Offline
          O Offline
          OldWarhorse
          wrote on last edited by
          #4

          :laugh: - You crack me up, Dude. Hey, the only dumb question is the one you should have asked and didn't, right? :)

          1 Reply Last reply
          0
          • O OldWarhorse

            System.IO.DriveInfo Boy, you're being a P.I.A. today. You're gonna owe me a cut of that app. :laugh:

            C Offline
            C Offline
            Code Crapper
            wrote on last edited by
            #5

            Ah hell now i came to another bottleneck... um (feels very stupid) how can i use this to display the actual total size of a drive because so far i can get it to say 16Bytes when it should be saying 250GB (well in that region)

            O 1 Reply Last reply
            0
            • C Code Crapper

              Ah hell now i came to another bottleneck... um (feels very stupid) how can i use this to display the actual total size of a drive because so far i can get it to say 16Bytes when it should be saying 250GB (well in that region)

              O Offline
              O Offline
              OldWarhorse
              wrote on last edited by
              #6

              Try something like this:

                  Dim dr As New System.IO.DriveInfo("C")
                  Dim sizeInBytes As Long
                  Dim sizeInGB As Single
              
                  sizeInBytes = dr.TotalSize
                  sizeInGB = sizeInBytes / 1000000000
                  TextBox1.Text = String.Format("Total Drive Size in Bytes:  {0}", sizeInBytes.ToString("#,###,###,###,###"))
                  TextBox2.Text = String.Format("Total Drive Size in GB:  {0}", sizeInGB.ToString("###,###,###,###.00"))
              

              You can play around with the verbage, divisor value, and formatting as you prefer.

              C 1 Reply Last reply
              0
              • O OldWarhorse

                Try something like this:

                    Dim dr As New System.IO.DriveInfo("C")
                    Dim sizeInBytes As Long
                    Dim sizeInGB As Single
                
                    sizeInBytes = dr.TotalSize
                    sizeInGB = sizeInBytes / 1000000000
                    TextBox1.Text = String.Format("Total Drive Size in Bytes:  {0}", sizeInBytes.ToString("#,###,###,###,###"))
                    TextBox2.Text = String.Format("Total Drive Size in GB:  {0}", sizeInGB.ToString("###,###,###,###.00"))
                

                You can play around with the verbage, divisor value, and formatting as you prefer.

                C Offline
                C Offline
                Code Crapper
                wrote on last edited by
                #7

                Yes!! thanks so much for this golden nugget i been searching for something like this for ages whew THANK YOU!! :-D

                O 1 Reply Last reply
                0
                • C Code Crapper

                  Yes!! thanks so much for this golden nugget i been searching for something like this for ages whew THANK YOU!! :-D

                  O Offline
                  O Offline
                  OldWarhorse
                  wrote on last edited by
                  #8

                  You're welcome! :-D (I gotta go do some nasty work for a while now. Fighting an 8-headed datagrid monster. Catch ya later. Happy coding.)

                  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