zoukankan      html  css  js  c++  java
  • 查找文件

    #include <iostream>
    #include <string>
    #include <windows.h>

    using namespace std;
    void find(char *IpPath)
    {
        char szFind[100];
        char szFile[100];
        WIN32_FIND_DATA FindFileData;
        strcpy(szFind,IpPath);
        strcat(szFind,"*.*");
        HANDLE hFind=::FindFirstFile(szFind,&FindFileData);
        if (INVALID_HANDLE_VALUE == hFind)
            return;
        while(true)
        {
            if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
            {
                if(FindFileData.cFileName[0]!='.')
                {
                    strcpy(szFile,IpPath);
                    strcat(szFile,"");
                    strcat(szFile,FindFileData.cFileName);
                    strcat(szFile,"\\*.*");
                    find(szFile);
                }
            }
            else
            {
                cout <<FindFileData.cFileName << endl ;
            }
            if(!FindNextFile(hFind,&FindFileData))
                break;
        }
        FindClose(hFind);
    }
    void main()
    {
        char *p="F:";
        find(p);
    }

     

  • 相关阅读:
    JSP获取input(含正则表达式)
    Computability 7: Exercises
    Network 5: Data Link Layer
    PRML 7: The EM Algorithm
    PRML 6: SVD and PCA
    PRML 5: Kernel Methods
    PRML 4: Generative Models
    Computability 6: Reducibility
    Distributed Hash Table
    Network 4: Network Layer
  • 原文地址:https://www.cnblogs.com/chengxin1982/p/1403515.html
Copyright © 2011-2022 走看看