求文件长度

#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

猜你喜欢

转载自blog.csdn.net/mianhuantang848989/article/details/77680093