How to get file-size of a file?
-
How can i implement one function to get the file size of a file which takes pointer to the file path?Please help..
-
How can i implement one function to get the file size of a file which takes pointer to the file path?Please help..
Hi Using Win32, you can use FindFirstFile and inspect the WIN32_FIND_DATA structure returned from that (and call FindClose when you leave). In .NET, that information is available from the FileInfo class. HTH Martin
-
How can i implement one function to get the file size of a file which takes pointer to the file path?Please help..
Why not use
GetFileSize()
?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
-
Why not use
GetFileSize()
?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
The function should take only the constant pointer to the path of the file..
-
The function should take only the constant pointer to the path of the file..
Ok, what's wrong with:
DWORD SizeOfFile( LPCTSTR lpszFile )
{
DWORD dwSize = 0;
HANDLE hFile;hFile = CreateFile(lpszFile, 0, 0, NULL, OPEN\_EXISTING, ...); if (hFile != INVALID\_HANDLE\_VALUE) { dwSize = GetFileSize(hFile, NULL); // you may want to use GetFileSizeEx() instead CloseHandle(hFile); } return (dwSize);
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
-
How can i implement one function to get the file size of a file which takes pointer to the file path?Please help..
Try CFile myFile(lpszFileName, CFile::modeRead); int len = myFile.GetLength(); Some people see things that are and ask, Why? Some people dream of things that never were and ask, Why not? Some people have to go to work and don't have time for all that ... Author: George Carlin