Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to obtain the size of a file without opening it. I have been told that GetFileAttributes is the way to do this - however, I am having great trouble in finding something which explains how. Could somebody help please, or show me an alternative. The main thing is that the method does not open the file.
Posted
Comments
GPUToaster™ 21-Oct-11 5:33am    
Try a google search, here are some links:
http://www.codeguru.com/forum/archive/index.php/t-440060.html
http://vmd.myxomop.com/apires/ref/g/getfileattributes.html
Jackie Lloyd 21-Oct-11 5:41am    
Hi, thankyou, I have done a lot of searching which is why i have finally resorted to posting the question on here. The frist link doesn't mention file size, and the second link is blocked form where I am at the moment.
Any suggestions please - it really is starting to drive me mad!

Use GetFileAttributesEx[^], not GetFileAttributes.
 
Share this answer
 
v2
Comments
Espen Harlinn 21-Oct-11 6:43am    
Right :)
Try this:

WIN32_FIND_DATA findFileData;
memset(&findFileData, 0, sizeof(WIN32_FIND_DATA));

HANDLE hFind = FindFirstFile(lpszFileName, &findFileData);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900