how to get size of file
plz explain with example
Printable View
how to get size of file
plz explain with example
MSDN:Quote:
Originally posted by shosha
how to get size of file
plz explain with example
Quote:
DWORD GetFileSize(
HANDLE hFile, // handle of file to get size of
LPDWORD lpFileSizeHigh
// pointer to high-order word for file size
);
Quote:
CFile::GetLength
For Opening the File:
For Getting the file size:Code:HANDLE hFile;
hFile = CreateFile("MYFILE.TXT", // create MYFILE.TXT
GENERIC_WRITE, // open for writing
0, // do not share
NULL, // no security
CREATE_ALWAYS, // overwrite existing
FILE_ATTRIBUTE_NORMAL | // normal file
FILE_FLAG_OVERLAPPED, // asynchronous I/O
NULL); // no attr. template
if (hFile == INVALID_HANDLE_VALUE)
{
ErrorHandler("Could not open file."); // process error
}
For Closing the File:Code:DWORD dwSize = GetFileSize(
hFile, //Handle to the file whose size is to be returned.
NULL //Pointer to the variable where the high-order word of the file size is returned.
);
if (dwSize != INVALID_FILE_SIZE)
<here display ur requested file's size ( dwSize ) >
CloseHandle(hFile);
I think it gives better info. on ur problem!