Find Free Drive space on windows
-
Hi All,
some of you know how can i retrive the free diskspace for example for drive "c:"?
Thanks and regards. -
Use GetDiskFreeSpaceEx() WinAPI function.
At linux you can use stat() and statfs() functions. -
QtMobility has API for that as well. You might want to take a look at that.
-
I've solved using code below:
@
LPCWSTR drive=L"F:\";ULARGE_INTEGER freeBytesToCaller;
freeBytesToCaller.QuadPart = 0L;if( !GetDiskFreeSpaceEx( drive, &freeBytesToCaller, NULL, NULL ) )
{
qDebug() << "ERROR: Call to GetDiskFreeSpaceEx() failed.";
}int freeSpace_gb = freeBytesToCaller.QuadPart;
qDebug() << "Free drive space: " << freeSpace_gb << "Bytes";
@But now i've another issue: How can i convert from QString to LPCWSTR, because in this way i could check about a driver stored into a QString obj.
Thanks. -
you can use:
@
(LPCWSTR)drive.utf16();
@ -
I've found exactly your solution after some tries:
@
QString qStr="YouString";
LPCWSTR drive1=(LPCWSTR)qStr.utf16();
@Thanks to all
-
"Look here":http://qt.gitorious.org/qt/qtsystems
-
The "boost filesystem library":http://www.boost.org/doc/libs/1_53_0/libs/filesystem/doc/index.htm could help you here. Look out for "space":http://www.boost.org/doc/libs/1_53_0/libs/filesystem/doc/reference.html#space.