獲取檔案大小,尤其是超過2G的大檔案

2021-05-05 14:01:26 字數 387 閱讀 5464

#define _file_offset_bits 64

#include

#include

#include

long long get_file_size(const char *filename)

return (long long)buf.st_size;

}long long ftell_test(const char *d)

int main(void)

有兩種方法,

一種是用 ftello, 一種是用stat函式。

重要的是要加上 #define _file_offset_bits 64

但是這兩個函式對塊裝置檔案,計算的結果不一致。

字元裝置好像是一樣的。

獲取檔案大小

1 找到檔案所在的絕對路徑。系統路徑 projectpath request.getsession getservletcontext getrealpath 檔案路徑 在上傳檔案的時候,一定會有檔案相對路徑,如果不清楚,可以打斷點然後在本地找到此檔案。檔案相對路徑 filepath 絕對路徑rea...

VC獲取檔案大小

vc獲取檔案大小 我查到兩種方法 方法一 win32 find data fileinfo handle hfind dword filesize const char filename 檔案的路徑及名字 hfind findfirstfile filename fileinfo if hfind ...

ORACLE獲取檔案大小

set serveroutput on declare ex boolean flen number bsize number begin utl file.fgetattr oraload test.txt ex,flen,bsize if ex then dbms output.put line...