How find particular file pattern path from directory MFC ?

Locked How find particular file pattern path from directory MFC ?

  • 13 มีนาคม 2555 19:05
     
     

    Hi All,

    I have a folder, in which there are so many file and out of that, one file name starts with "test".Now, i want to find the entair file path.How should i do this?

    here is how i'm trying to do...

    CString strFilePath = _T("D:\PL001");

    CString patterns = _T("test*");

    I want to find the path like : D:\PL001\test.txt

    Pls advice...


    • แก้ไขโดย RoutJ 13 มีนาคม 2555 19:08
    •  

ตอบทั้งหมด

  • 13 มีนาคม 2555 19:26
     
     คำตอบ
    Try Win32 methods FindFirstFile and FindNextFile.
  • 13 มีนาคม 2555 19:26
     
     

    Use FindFirstFile and FindNextFile as shown here:

    http://msdn.microsoft.com/en-us/library/windows/desktop/aa364418(v=vs.85).aspx

  • 13 มีนาคม 2555 23:14
     
     

    You may want to take a look at this class as well if you want to do something more specific.

    CFileFindEx

    I use it all the time...

    Tom

  • 14 มีนาคม 2555 3:12
     
     

    You may want to take a look at this class as well if you want to do something more specific.

    CFileFindEx

    I use it all the time...

    Tom

    Tom,Thanks for help.This is what i was looking for,But;

    Getting error:

    Can not include such file #include "filefindex.h" , no such file in the directory.

    Why this error and how to reslove this?

    I'm using VS2008 and my peoject is Win32 console application with MFC support.


    Jyotiranjan

  • 14 มีนาคม 2555 6:36
     
     

    Hi,

    You should download the .zip file from that link and copy the files from it.  If you are using a version newer than VS 2005 you will also need to get the atlrx.h file from:

    AtlServer

    And copy the file from the zip to your project as well.

    1. Download my code from Codeproject.
    2. Download the ATL source from the link above (to get the atlrx.h file.
    3. Add FindFileEx.h, FindFileEx.cpp, and atlrx.h to your project.
    4. Include FindFileEx.h where you want to use it.

    Tom