c++ - Get File size from CFileDialog -
i newbie visual studio c++. using cfiledialog file name , file path user input. , want use progress control loading process , user have wait depend on input file size. got file name , file path using cfiledialog don't know how user input file size.
i using below method , return zero.
int filesize(const char * szfilename) { struct stat filestat; int err = stat(szfilename, &filestat); if (0 != err) return 0; return filestat.st_size; } please suggest me if have better solution file size.
thanks much.
the standard portable way be:
long long sz; // int small many files ! ifstream ifs(test); if(!ifs) return 0; // when file couldn't opened ifs.seekg(0, ios::end); sz = ifs.tellg(); return sz; the native windows approach use getfilesize().
but if @ mfc alternative doesn't open file first, may @ this question.
Comments
Post a Comment