Quickest Way To Find File Size Of File Opened With fopen()

This topic is 5058 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Whats the quickest way to do this. regards ace

Share on other sites
'Quickest' is a bit ambiguous - are you talking about execution speed of time taken to write the code? Whichever, look up the ftell function.

Skizz

Share on other sites
Here's an example:

//open the fileFILE *FilePtr = fopen("Foo.txt", "rb");//seek to the last bytefseek(FilePtr, 0, SEEK_END);//ftell returns the current file ptr position, for binary streams//this is the number of bytes from the beginning of the file so in //this case it'll return the filesizelong FileSize = ftell(FilePtr);

May not be the quickest way to do it but it's the only way I've seen.

Share on other sites
Look up GetFileSize().

Share on other sites
hehe, u never guess what i used to do,

read bytes till the ens is found
LOLOLOLOLOL

ace

Share on other sites
while someone already suggested opening the file and using either ftell() or GetFileSize(), if speed is important to you, use FindFirstFile() instead. opening a file is always slow(er).

Share on other sites
Quote:
 Original post by Anonymous Posterwhile someone already suggested opening the file and using either ftell() or GetFileSize(), if speed is important to you, use FindFirstFile() instead. opening a file is always slow(er).

To quote the topic, "Quickest Way To Find File Size Of File Opened With fopen()".

If it's not, the AP has a point, going by base execution speed (although I wouldn't say allways, as I bet someone could think of some really archaic example where this isn't the case XD).

1. 1
2. 2
Rutin
22
3. 3
4. 4
frob
17
5. 5

• 33
• 13
• 12
• 10
• 12
• Forum Statistics

• Total Topics
632573
• Total Posts
3007139

×