こんな感じでとりあえずOKでした。
#include <iostream>
#include <fstream>
using namespace std;
void foo( string strInputFilename )
{ // ファイルを開きます
ifstream istrm(strInputFilename.c_str(), ios::binary);
// 入力ファイルのファイルサイズ保存用変数
size_t sizeInfile ;
// ファイルポインタを末尾へ
istrm.seekg(0, ifstream::end);
// ファイルサイズを取得
sizeInfile = static_cast<size_t>(istrm.tellg());
// (いちおう)ファイルポインタを先頭へ。無くても良いです。
istrm.seekg(0, ifstream::beg);
}
NOTE
ファイルサイズを知りたい場合は、c++17 で加わった std::filesystem::file_size を使用しましょう。
| 2021-08-12 | - | 体裁更新とちょこっと追記 |
| 2009-12-26 | - | 新規作成 |