Chinaunix首页 | 论坛 | 博客
  • 博客访问: 45119
  • 博文数量: 21
  • 博客积分: 1425
  • 博客等级: 上尉
  • 技术积分: 215
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-29 21:56
文章分类

全部博文(21)

文章存档

2009年(19)

2008年(2)

我的朋友

分类: C/C++

2009-09-05 11:26:09

    // 方法一
    struct _stat info;
    _stat(filepath, &info);
    int size = info.st_size;
    cout<
    // 方法二
    FILE* file = fopen(filepath, "rb");
    if (file)
    {
        int size = filelength(fileno(file));
        cout<        fclose(file);
    }
    // 方法三
    CFile cfile;
    if (cfile.Open(filepath, CFile::modeRead))
    {
        int size = cfile.GetLength();
        cout<    }
    // 方法四
    HANDLE handle = CreateFile(filepath, FILE_READ_EA, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
    if (handle != INVALID_HANDLE_VALUE)
    {
        int size = GetFileSize(handle, NULL);
        cout<        CloseHandle(handle);
    }
    //方法五
    long getfilesize(const char * filename)
    {
        FILE *fp;
        long lRet;
        if ((fp = fopen(filename, "r")) == NULL)
        return 0;
        fseek(fp, 0, SEEK_END);
        lRet = ftell(fp);
        fclose(fp);
        return lRet;
    }
阅读(615) | 评论(0) | 转发(0) |
0

上一篇:常用网站

下一篇:GetLocalIP-windows

给主人留下些什么吧!~~