Click here to Skip to main content
15,887,304 members
Please Sign up or sign in to vote.
4.33/5 (2 votes)
See more:
I open file using
myfile = _wopen(your_result,O_BINARY|_O_RDONLY,_S_IREAD);//'myfile' is the file descriptor which is return by _wopen ,
seek is done by using
lseek(myfile,00,SEEK_END)
how i can get the file size using this file descriptor
Posted

Using C-like API (as you are doing) with ftell: see "function ftell"[^] for sample code.
 
Share this answer
 
Comments
Member 10608347 1-Apr-14 6:52am    
inside ftell file pointer is need here i have file descriptor,ftell is not working
 
Share this answer
 
From here:

http://stackoverflow.com/questions/238603/how-can-i-get-a-files-size-in-c[^]

When using file descriptor.

C++
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

struct stat buf;
fstat(fd, &buf);
int size = buf.st_size;
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900