-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi All,
I want to know the size of file (txt,img or any other file). i knoe
only file name.
how i can acheive this.
does anybody is having idea about that.
plz help.
I can only think of two methods to determine file size that are consistant with
the C standard:
1) fopen() the file,
initialize an unsigned long (or longer) variable to 0
until fgetc() returns end of file, add 1 to the counter
fclose() the file,
or
2) fopen() the file
fseek() to the end of the file
ftell() the position of the end of the file
fclose() the file
Both of these methods have their drawbacks. Character counting may give
different results depending on whether the file was opened in binary or text
mode, and fseek()/ftell() may or may not work, depending on the implementation
("a binary stream need not meaningfully support fseek calls with a whence value
of SEEK_END" and ftell() return value is either the absolute position (when used
on a binary stream), or some "unspecified information" when used on a text stream).
Your choice.
- --
Lew Pitcher
IT Specialist, Enterprise Data Systems,
Enterprise Technology Solutions, TD Bank Financial Group
(Opinions expressed are my own, not my employers')
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
iD8DBQFC+1XaagVFX4UWr64RAhyzAKCYNfPqV64rRBZ5p6SoxZoJxMvp5gCg7C80
colQvhV5MvyjLy/zhrNDSgA=
=CstA
-----END PGP SIGNATURE-----