Re: Determining File Size
- From: Ulrich Eckhardt <eckhardt@xxxxxxxxxxxxxx>
- Date: Fri, 28 Apr 2006 09:08:07 +0200
Rich S. wrote:
What function in the C-Runtime will tell me the size of a disk file?
In C, that would be the function stat(), in win32 you could use
GetFileAttributes(). There is also the Boost filesystem library, if you're
concerned about portability, which also has such methods.
It looks like ifstream does not have a member that will tell file size.
You can search to the end of the file and then use tellg() to get the
current position. However, while this works in most cases, there is the
problem that the returnvalue of tellg() is not necessarily in bytes, it
only makes sense in the context of seekg(). I'd use above methods.
Uli
.
- Prev by Date: Re: vector of structs?
- Previous by thread: vector of structs?
- Index(es):