#include <fstream> #include <limits> ifstream file; file.open(name,std::ios::in|std::ios::binary); file.ignore( std::numeric_limits<std::streamsize>::max() ); std::streamsize length = file.gcount(); file.clear(); // Since ignore will have set eof. file.seekg( 0, std::ios_base::beg );