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. C / C++ / MFC
  3. How can I get the first file of FindFile?

How can I get the first file of FindFile?

Scheduled Pinned Locked Moved C / C++ / MFC
3 Posts 3 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.
  • M Offline
    M Offline
    Michael Menne
    wrote on last edited by
    #1

    If I search a file with: CFileFind fFind; find.FindFile("*.bmp"); find.GetFilePath(); the programm crashes. MSDN says that I must call FindNextFile() at least once, but then I get the path of the second file and not of the first. So, how can I get the path of the first file?:confused:

    G W 2 Replies Last reply
    0
    • M Michael Menne

      If I search a file with: CFileFind fFind; find.FindFile("*.bmp"); find.GetFilePath(); the programm crashes. MSDN says that I must call FindNextFile() at least once, but then I get the path of the second file and not of the first. So, how can I get the path of the first file?:confused:

      G Offline
      G Offline
      Gero Gerber
      wrote on last edited by
      #2

      There seems to be a bug in the MFC class of CFileFind. Use instead FindNextFile() of the Win32 Platform SDK.

      1 Reply Last reply
      0
      • M Michael Menne

        If I search a file with: CFileFind fFind; find.FindFile("*.bmp"); find.GetFilePath(); the programm crashes. MSDN says that I must call FindNextFile() at least once, but then I get the path of the second file and not of the first. So, how can I get the path of the first file?:confused:

        W Offline
        W Offline
        Wayne Fuller
        wrote on last edited by
        #3

        No, there is no bug. You have to call FindNextFile at least once just like the documentation states. Basically this is what you do. CFileFind fFind; BOOL bFound = fFind.FindFile( "*.bmp" ); while ( bFound ) { bFound = fFind.FindNextFile(); // Do what you want with fFind, it is pointing to the first found file. } Hope that helps Wayne

        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