File Search
-
I had asked yesterday if there was a way to look at all the files in a directory and I was directed to CFileFind, but for some reason, as I use .FindNextFile() and .GetFileName(), it's skipping like 4 files every time! Any help? Danny
Post the code
-
I had asked yesterday if there was a way to look at all the files in a directory and I was directed to CFileFind, but for some reason, as I use .FindNextFile() and .GetFileName(), it's skipping like 4 files every time! Any help? Danny
Actually, I have to retract that question. It does seem to search all the files, just in a different order than I would have expected. It does seem, though, that when I try to open the file just after I found it that the file doesn't open. Here's the code I'm working with... CFileFind finder; BOOL bWorking = finder.FindFile(searchPath); while (bWorking) { bWorking = finder.FindNextFile(); fileList[counter] = (LPCTSTR) finder.GetFileName(); path = (LPCTSTR) finder.GetFilePath(); examine.open(path, ios::in | ios::nocreate | ios::noreplace); . . . } (fileList is an array of CStrings, path is a CString, and examine is an fstream.) Is the finder possibly interfering with opening the file? Danny
-
Actually, I have to retract that question. It does seem to search all the files, just in a different order than I would have expected. It does seem, though, that when I try to open the file just after I found it that the file doesn't open. Here's the code I'm working with... CFileFind finder; BOOL bWorking = finder.FindFile(searchPath); while (bWorking) { bWorking = finder.FindNextFile(); fileList[counter] = (LPCTSTR) finder.GetFileName(); path = (LPCTSTR) finder.GetFilePath(); examine.open(path, ios::in | ios::nocreate | ios::noreplace); . . . } (fileList is an array of CStrings, path is a CString, and examine is an fstream.) Is the finder possibly interfering with opening the file? Danny
bugDanny wrote: fileList[counter] = (LPCTSTR) finder.GetFileName(); path = (LPCTSTR) finder.GetFilePath(); While not related to the actual problem, the two casts are unnecessary.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
-
Actually, I have to retract that question. It does seem to search all the files, just in a different order than I would have expected. It does seem, though, that when I try to open the file just after I found it that the file doesn't open. Here's the code I'm working with... CFileFind finder; BOOL bWorking = finder.FindFile(searchPath); while (bWorking) { bWorking = finder.FindNextFile(); fileList[counter] = (LPCTSTR) finder.GetFileName(); path = (LPCTSTR) finder.GetFilePath(); examine.open(path, ios::in | ios::nocreate | ios::noreplace); . . . } (fileList is an array of CStrings, path is a CString, and examine is an fstream.) Is the finder possibly interfering with opening the file? Danny
The order you see is dependant upon the underlying file system. For NTFS, you will generally see the files in alphabetical order by name. For FAT32, it's in 'directory' order, which is generally the order in which the files were added to the directory. bugDanny wrote: Is the finder possibly interfering with opening the file? Doubtful. Try debugging your
examine.open
function with a hand-entered, known good file path.
Software Zen:
delete this;