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. Web Development
  3. ASP.NET
  4. how to find the disk space of a drive in Windows Services

how to find the disk space of a drive in Windows Services

Scheduled Pinned Locked Moved ASP.NET
tutorialquestion
6 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.
  • R Offline
    R Offline
    ramyasangeet
    wrote on last edited by
    #1

    hi all, I am working on a Windows Services where i need to find the disk space of C: drive.Is it possible? Can u plz give some suggestions.. Thanks in advance,

    cheers sangeet

    S S R 3 Replies Last reply
    0
    • R ramyasangeet

      hi all, I am working on a Windows Services where i need to find the disk space of C: drive.Is it possible? Can u plz give some suggestions.. Thanks in advance,

      cheers sangeet

      S Offline
      S Offline
      Sylvester george
      wrote on last edited by
      #2

      Give score if it worths for you. ================================ DriveInfo[] allDrives = DriveInfo.GetDrives(); foreach (DriveInfo d in allDrives) { Console.WriteLine("Drive {0}", d.Name); Console.WriteLine(" File type: {0}", d.DriveType); if (d.IsReady == true) { Console.WriteLine(" Volume label: {0}", d.VolumeLabel); Console.WriteLine(" File system: {0}", d.DriveFormat); Console.WriteLine( " Available space to current user:{0, 15} bytes", d.AvailableFreeSpace); Console.WriteLine( " Total available space: {0, 15} bytes", d.TotalFreeSpace); Console.WriteLine( " Total size of drive: {0, 15} bytes ", d.TotalSize); } }

      Regards, Sylvester G Senior Software Engineer Xoriant Solutions sylvester_g_m@yahoo.com

      1 Reply Last reply
      0
      • R ramyasangeet

        hi all, I am working on a Windows Services where i need to find the disk space of C: drive.Is it possible? Can u plz give some suggestions.. Thanks in advance,

        cheers sangeet

        S Offline
        S Offline
        Sandeep Akhare
        wrote on last edited by
        #3

        But at the server side only using this code System.IO.DriveInfo drive = new System.IO.DriveInfo("C"); play with drive object i hope it will help you

        Thanks and Regards Sandeep

        1 Reply Last reply
        0
        • R ramyasangeet

          hi all, I am working on a Windows Services where i need to find the disk space of C: drive.Is it possible? Can u plz give some suggestions.. Thanks in advance,

          cheers sangeet

          R Offline
          R Offline
          ramyasangeet
          wrote on last edited by
          #4

          hey thanks for ur help..i got it.. but the totalspace,totalfree space are in bytes..how do i convert it to MB or GBs. Thanks again for ur help..

          cheers sangeet

          S 1 Reply Last reply
          0
          • R ramyasangeet

            hey thanks for ur help..i got it.. but the totalspace,totalfree space are in bytes..how do i convert it to MB or GBs. Thanks again for ur help..

            cheers sangeet

            S Offline
            S Offline
            Sandeep Akhare
            wrote on last edited by
            #5

            Apply logic 1024 bytes =1 Mb \ do calculations

            Thanks and Regards Sandeep

            R 1 Reply Last reply
            0
            • S Sandeep Akhare

              Apply logic 1024 bytes =1 Mb \ do calculations

              Thanks and Regards Sandeep

              R Offline
              R Offline
              ramyasangeet
              wrote on last edited by
              #6

              yes i got it..thanks a lot..

              cheers sangeet

              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