如何得到文件大小?

yzkzero 2003-01-08 03:13:09
有什么办法直接得到某个file的大小
...全文
83 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
rafter263 2003-01-08
  • 打赏
  • 举报
回复
void anyway()
{
CFile file;
file.Open("d:\\test\\test.cpp",CFile::modeRead,NULL);
DWORD sz=GetFileSize((void*)file.m_hFile,NULL);//单位是字节
}
ydyuse 2003-01-08
  • 打赏
  • 举报
回复
filelength()不行吗?
lw549 2003-01-08
  • 打赏
  • 举报
回复
如果是在c中
可以
fseek(file* SEEK_END);/*就是到文件结尾,我记不清楚是不是SEEK_END了*/
filelength=ftell(file*);
sunwhite 2003-01-08
  • 打赏
  • 举报
回复
关注
web_spider 2003-01-08
  • 打赏
  • 举报
回复
#include <iostream>
#include <fstream>
using namespace std;

int main(int argc, char* argv[])
{
ifstream in(argv[1]);
in.seekg(0, ios::end); // End of file
streampos sp = in.tellg(); // Size of file
cout << "file size = " << sp << endl;
}

69,336

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧