filesize - Using C++ filestreams (fstream), how can you determine the size of a file? - Stack Overflow
Mon Mar 21 2022 10:16:15 GMT+0000 (Coordinated Universal Time)
Saved by
@jay
#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 );
content_copyCOPY
https://stackoverflow.com/questions/2409504/using-c-filestreams-fstream-how-can-you-determine-the-size-of-a-file
Comments