Why do you need to know the length of the file before you open it?
Right now I can't think of a way to do that, but otherwise, you can use _filelength(handle) in io.h (this is used with _open, _read, _write, and _close).