Hello, It seems like a simple task, but I can't find a simple answer.

How do you find out how much extra space you have on drive "X:\".

Is there any simple command like; Size(X:\); ?

Or can someone just give me a few lines of code, NOT 53! I just want that part.

Also, What librairies do I need to include?

Recommended Answers

All 4 Replies

I don't know if this is available on Windows, but on Linux/Unix/Posix systems there is are two functions statvfs() and fstatvfs() that fill a structure that includes the size of blocks on the device and the number of free blocks. All you need to do to find available space is multiply one (f_bsize) by the other (f_bfree). Thats about as simple as you can get, at least on *ix systems. FWIW, I know that Windows does have Posix API's, so they might have these functions, but knowing Microsoft, they also have their own version. Sorry that my MSDN library isn't installed on my system right now, so I can't look it up.

Hello tailsthefox,
System("DIR") will display the directories of the drive and the number of free space available in bytes. But before doing system("DIR") you must change to the required drive. You need to include stdlib for executing system commands.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.