Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. File Search

File Search

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bugDanny
    wrote on last edited by
    #1

    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

    C B 2 Replies Last reply
    0
    • B bugDanny

      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

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      Post the code

      1 Reply Last reply
      0
      • B bugDanny

        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

        B Offline
        B Offline
        bugDanny
        wrote on last edited by
        #3

        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

        D G 2 Replies Last reply
        0
        • B bugDanny

          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

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • B bugDanny

            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

            G Offline
            G Offline
            Gary R Wheeler
            wrote on last edited by
            #5

            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;

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups