I am playing about trying to catalogue the files on a hard disk (It just seemed a reasonable project to do, it will make me think on recursion, file access, and using some MFC features)
Below is a small fragment of code. The last line of the code is the point at which my system crashes, and throws an out of memory exception.
BUT
Through a form, the user can specify at which point (folder) that the cataloguing starts from). For some folders, the new statement throws, for others it doesn't.
The path to get to the folder doesn't seem to be at issue.
The exception is always thrown for these folders. If the loop had begun processing I could maybe understand why I was getting an out of error message. But it hasn't, all it has done is try to allocate some memory for a pointer to a structure (the structure is 248 bytes in fact)
Can anyone explain to me why this is, or even just give me some more ideas as to where I can look to begin to identify what is causing this ?
Thanks
K
Below is a small fragment of code. The last line of the code is the point at which my system crashes, and throws an out of memory exception.
BUT
Through a form, the user can specify at which point (folder) that the cataloguing starts from). For some folders, the new statement throws, for others it doesn't.
The path to get to the folder doesn't seem to be at issue.
The exception is always thrown for these folders. If the loop had begun processing I could maybe understand why I was getting an out of error message. But it hasn't, all it has done is try to allocate some memory for a pointer to a structure (the structure is 248 bytes in fact)
Can anyone explain to me why this is, or even just give me some more ideas as to where I can look to begin to identify what is causing this ?
Thanks
K
Code:
//Find the First Entry in this Folder, be it a Directory or a File
HANDLE hFind = FindFirstFile(lpFind,&lpData);
//Check Handle to see if an Error
if (hFind == INVALID_HANDLE_VALUE)
{
return false;
}
//Find First Removes the '.' directory
//This FindNext removes the '..' directory
BOOL blNextFile = FindNextFile(hFind, &lpData);
//Look at the First Valid File in the Directory
blNextFile = FindNextFile(hFind, &lpData);
//If 0 then an Error - Throw the relevant Exception
if (!blNextFile)
DWORD dwError = GetLastError();
while(blNextFile)
{
//Create a File Header Object in Memory
sFileRecord* sFR = new sFileRecord;