求文件长度

来源:互联网 发布:淘宝网服装男装 编辑:程序博客网 时间:2024/05/22 09:01
#if 0
unsigned int filesize = 0;   
struct stat statbuff; 
stat(file_name, &statbuff);
filesize = statbuff.st_size; 
sendfile( socket_id, myfp, NULL, filesize);  
#else 
fseek(myfp, 0, SEEK_END);// 指定到文件尾
unsigned int filesize = ftell(myfp);//获取文件长度
fseek(myfp, 0, SEEK_SET);//指定到文件头
#endif