方法一:
方法二:
WIN32_FIND_DATA fileInfo;
HANDLE hFind;
DWORD fileSize;
const char *fileName = 文件的路径及名字;
hFind = FindFirstFile(fileName ,&fileInfo);
if(hFind != INVALID_HANDLE_VALUE)
fileSize = fileInfo.nFileSizeLow;
FindClose(hFind);
方法二:
HANDLE hFile; // the file handle
DWORD dwFileSize; // temporary storage for file sizes
// Create the test file. Open it "Create Always" to overwrite any
// existing file. The data is re-created below.
hFile = CreateFile(lpcTheFile, GENERIC_READ | GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
printf("hFile is NULL\n");
return 4;
}
dwFileSize = GetFileSize(hFile, NULL);
printf("hFile size: %10d\n", dwFileSize);