LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

getfilesize error

Hello,

 

I am using GetFileSize function to read a file size, and I think I am running into the dreaded 2 gb file size limit for 32 bit applications, since this works for all files below 2 gb. I am using the 64 bit debug as the build but when attempt to get the size for a large file (2,278,153,276 bytes) I get an error: 

NON-FATAL RUN-TIME ERROR: Function CVI_GetFileSize: (return value == -3 [0xfffffffffffffffd]). 

-3 General I/O error occurred.

In my code:

static char file_nameEDF[MAX_PATHNAME_LEN];

ssize_t size64;

 

if(FileSelectPopup ("", "*.edf", "*.edf","Name of File to Read", VAL_LOAD_BUTTON, 0, 0, 1, 1, file_nameEDF)>0){
GetFileSize(file_nameEDF, &size64);

}

 

Is there another function I should be using?

 

Thank you,

0 Kudos
Message 1 of 3
(2,583 Views)

GetFileSizeEx from the Win32API should do the trick:

 

#include <windows.h>

__int64	size64;
HANDLE	hFile;

hFile = CreateFile(file, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
GetFileSizeEx (hFile, (PLARGE_INTEGER)&size64);
DebugPrintf ("File size is %I64d bytes\n", size64);
CloseHandle (hFile);

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 3
(2,556 Views)

As an alternative, if you do not want to actually open the file, try this:

 

#include <windows.h>

WIN32_FILE_ATTRIBUTE_DATA	fAttrData;
LARGE_INTEGER			size64;

GetFileAttributesEx (
		file,				//__in  LPCTSTR lpFileName,
		GetFileExInfoStandard,		//__in  GET_FILEEX_INFO_LEVELS fInfoLevelId,
		&fAttrData			//__out LPVOID lpFileInformation
);
size64.u.LowPart = fAttrData.nFileSizeLow;
size64.u.HighPart = fAttrData.nFileSizeHigh;
DebugPrintf ("File size is %I64d bytes\n", size64.QuadPart);

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 3 of 3
(2,554 Views)