GetDiskFreeSpaceEx And Terrabyte

Ocrana
Ocrana used Ask the Experts™
on
Hi,

I have a function where I check the available diskspace before start to save. It works well but if I query our 9 Terrabyte Networkdrive I got allways the message "Not enough space". Here I use:
      float theSize = theApp.appHelpers.PixGetFreeDiskSpace(oPathInfo.GetDrive());
      if(theSize<4482){    //Space in MB for a DVD Image
         //Error
         MessageBox(L"Not Enough Space");
         return FALSE;
      }
With the function in the code area. What do I worng?

Ocrana


double CPixbyteHelpers::PixGetFreeDiskSpace(CString tDrive)
{
	ULARGE_INTEGER uliFreeBytesAvailable,uliTotalNumberOfBytes,uliTotalNumberOfFreeBytes;
	uliFreeBytesAvailable.QuadPart = 0L;
	uliTotalNumberOfBytes.QuadPart = 0L;
	uliTotalNumberOfFreeBytes.QuadPart = 0L;

	if (!GetDiskFreeSpaceEx(tDrive,&uliFreeBytesAvailable,&uliTotalNumberOfBytes,&uliTotalNumberOfFreeBytes))
	{
		return -1; // could not get info.
	}

	//return megabytes free.
	return (uliTotalNumberOfFreeBytes.QuadPart/1024.0/1024.0);
}

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
well, you could start by figuring out what uliTotalNumberOfFreeBytes.QuadPart is.

other suggestion is to call GetLastError http://msdn.microsoft.com/en-us/library/ms679360(VS.85).aspx
lpDirectoryName :
If this parameter is a UNC name, it must include a trailing backslash, for example, "\\MyServer\MyShare\".

do you use UNC ? did you add the trailing "\" ?


If GetDiskFreeSpaceEx() fails do not just return -1 and then ignore the result.

float theSize = theApp.appHelpers.PixGetFreeDiskSpace(oPathInfo.GetDrive());
if ( theSize  == -1 ) {
         MessageBox(L"GetDiskFreeSpaceEx fails");
         return FALSE;
}
if(theSize<4482){    //Space in MB for a DVD Image
         //Error
         MessageBox(L"Not Enough Space");
         return FALSE;
}

Author

Commented:
It was a UNC problem. Thanks for the hint.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial