LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Get size of file bigger than 2/4GBytes

I am trying to get the size of huge file (>2/4GBytes) and use the GetFileSizeEx function but High and low part returned have no relation with the good file size.
Same problem with function GetDiskFreeSpaceEx to know how many bytes are free on a local hard drive.

Is there anybody who can help me to convert these LARGE_NUMBER value in good value?

I am using CVI6.0 FDS under WinXP.

Nicolas,
0 Kudos
Message 1 of 2
(3,185 Views)
Based on an example from MSDN

const char Drive[4];
int Error;
ULARGE_INTEGER FreeBytesAvailableToCaller = {0.0,0.0};
ULARGE_INTEGER TotalNumberOfBytes = {0.0,0.0};
ULARGE_INTEGER TotalNumberOfFreeBytes = {0.0,0.0};
double Total_Size = 0.0;
double Free_Size = 0.0;
char Total[256];
char Available[256];

Fmt(Drive,"C:\\");

Error = GetDiskFreeSpaceEx(Drive,&FreeBytesAvailableToCaller,&TotalNumberOfBytes,&TotalNumberOfFreeBytes);
if ( Error == 0 )
{
MessagePopup ("Error","Error, Could not read Disk!");
}

Total_Size = (LONGLONG)TotalNumberOfBytes.QuadPart;
Free_Size = (LONGLONG)TotalNumberOfFreeBytes.QuadPart;

Total_Size /= (1024 * 1024 * 1024);
Free_Size /= (1024 * 1024 * 1024);

Fmt (Total,"%f GB",Total_Size);
Fmt (Available,"%f GB",Free_Size);
Message 2 of 2
(3,174 Views)