How can I get the file size of a file
C / C++ / MFC
4
Posts
4
Posters
0
Views
1
Watching
-
Hello, How can I get the file size of a file using standard C++ library (not MFC)? Thanks!! Nachi
Do you mean, a function like _filelength ?
-
Hello, How can I get the file size of a file using standard C++ library (not MFC)? Thanks!! Nachi
#include #include using namespace std; int main() { fstream file; int size = 0; file.open("test.txt",ios::in); //Replace test.txt with file name if(file.is_open()) { file.seekp(0,ios::end); //Move position of stream to the end size = file.tellp(); //Get position at end which tells size file.close(); } cout << "File size: " << size << endl; return 0; }
-
Hello, How can I get the file size of a file using standard C++ library (not MFC)? Thanks!! Nachi