Hi,
I am opening a file using "fopen" function.
How can I know the file length ?

Yoav.

Re: get the length of a file by Tom

Tom
Wed Feb 28 09:46:36 CST 2007

You could fseek() to the end then use ftell() to get the position. However,
you may run into trouble if the file is really large.

You could also use GetFileSize() if you open the file with CreateFile() or
you could use CFile if you are using MFC.

Tom

"Yoavo" <yoav@cimatron.co.il> wrote in message
news:uigiIs0WHHA.1036@TK2MSFTNGP03.phx.gbl...
> Hi,
> I am opening a file using "fopen" function.
> How can I know the file length ?
>
> Yoav.
>


Re: get the length of a file by William

William
Wed Feb 28 09:49:49 CST 2007

"Yoavo" <yoav@cimatron.co.il> wrote in message
news:uigiIs0WHHA.1036@TK2MSFTNGP03.phx.gbl...
> I am opening a file using "fopen" function.
> How can I know the file length ?

Check the docs for fseek() and ftell(). One option is to seek to the end of
the file and then to request for the current file pointer with ftell().

Regards,
Will
www.ivrforbeginners.com



Re: get the length of a file by Alex

Alex
Wed Feb 28 10:52:25 CST 2007

"Yoavo" wrote:
> Hi,
> I am opening a file using "fopen" function.
> How can I know the file length ?


FILE* f = fopen(...);

int fd = _fileno(f);

// if a file's smaller than 2GB
long length1 = _filelength(fd);

// if a file can be larger than 2GB
__int64 length2 = _filelengthi64(fd);


HTH
Alex



Re: get the length of a file by beginthreadex

beginthreadex
Thu Mar 01 09:44:48 CST 2007

FindFirstFile returns a struct that you can see the size of the file.
Just use that.

On Wed, 28 Feb 2007 17:16:42 +0200, "Yoavo" <yoav@cimatron.co.il>
wrote:

>Hi,
>I am opening a file using "fopen" function.
>How can I know the file length ?
>
>Yoav.
>


Re: get the length of a file by Matt

Matt
Thu Mar 01 13:28:37 CST 2007

"Yoavo" <yoav@cimatron.co.il> wrote in message
news:uigiIs0WHHA.1036@TK2MSFTNGP03.phx.gbl...
> Hi,
> I am opening a file using "fopen" function.
> How can I know the file length ?

GetFileAttributesEx ()



Re: get the length of a file by Ben

Ben
Tue Mar 13 11:11:14 CDT 2007


"Yoavo" <yoav@cimatron.co.il> wrote in message
news:uigiIs0WHHA.1036@TK2MSFTNGP03.phx.gbl...
> Hi,
> I am opening a file using "fopen" function.
> How can I know the file length ?

fstat

>
> Yoav.
>