How to find hard disk space (free) through c++ code?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rag84dec
    New Member
    • Mar 2007
    • 100

    How to find hard disk space (free) through c++ code?

    HI,
    Can anyone give me some idea?
  • archonmagnus
    New Member
    • Jun 2007
    • 113

    #2
    Without interfacing a specific API, you could pipe the output from the system command into a file and read-in the disk space. For example:

    [CODE=cpp]
    // For Unix, Linux, BSD, etc.
    system("df -hl [disk or mount point] > output.txt");

    // For Windows/DOS
    system("dir /-C [disk] > output.txt");

    // Where [disk] could be: "C:", "/dev/sdb1", etc.
    [/CODE]
    Then you simply have to open the file "output.txt " and parse the disk sizes back in.

    Comment

    • vpawizard
      New Member
      • Nov 2006
      • 66

      #3
      Use the system calls or API.

      Comment

      Working...