Thứ Ba, 19 tháng 7, 2011

Get all file's name and subdirectory from directory 's path

If you want to get all file's name from folder's path in C++, you can use many way. I know one way which can help you to do this work.
There are some steps you have to do:
+ The first, you must add chain: "\\*.*" after your path.
+ The second, calling FindFirstFileA function to find the first file in your folder
+ Then you calling FindNextFileA function to find all file to the end
And this is my source code that you can use:

   // You have to use windows.h and tchar.h library

    char * pathFolder = "D:";
    char* FileNext;
    WIN32_FIND_DATAA  findFile;
    HANDLE hfind;
    char folderFind[255];
    int isFinish;

   sprintf(folderFind,"%s\\*.*",pathFolder);
    hfind = FindFirstFileA(folderFind,&findFile);
    isFinish = FindNextFileA(hfind,&findFile);     


    while(isFinish)
    {
        FileNext = findFile.cFileName;                      // Do with your file's name
        isFinish = FindNextFileA(hfind,&findFile);  
    }

Best wishes for you. Thanks for visting my blog!
Do your best, the rest will come!

Không có nhận xét nào:

Đăng nhận xét

Install Kubernetes using kubeadm with two nodes master & worker

Well come back for a long time my friends! Today I want to take a note about some basic knowledge about Kubernetes. I hope that it will...