我如何...如何找到文件的大小 [英] How Do I...How Do I Find The Size Of A File

查看:83
本文介绍了我如何...如何找到文件的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用
打开文件
myfile = _wopen(your_result,O_BINARY | _O_RDONLY,_S_IREAD); //'myfile'是_wopen返回的文件描述符,

搜索是通过使用

lseek(myfile,00,SEEK_END)完成的。

如何使用此文件描述符获取文件大小

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

推荐答案

使用 C -like API (正如您所做) ftell :请参阅function ftell [ ^ ]示例代码。
Using C-like API (as you are doing) with ftell: see "function ftell"[^] for sample code.


访问这里...



http://www.cplusplus .com / forum / windows / 10853 / [ ^ ]
visit here...

http://www.cplusplus.com/forum/windows/10853/[^]


从这里:



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



使用文件描述符时。



From here:

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

When using file descriptor.

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

struct stat buf;
fstat(fd, &buf);
int size = buf.st_size;


这篇关于我如何...如何找到文件的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆