Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • C++

Idiom #95 Get file size

Assign to variable x the length (number of bytes) of the local file at path.

#include <fstream>
std::ifstream f(path, std::ios::in | std::ios::binary);
f.seekg(0, std::ios::end);
size_t x = f.tellg();
with Ada.Directories; use Ada.Directories;
X : constant File_Size := Size (Path);

New implementation...
< >
programming-idioms.org