zoukankan      html  css  js  c++  java
  • 获取某个目录下所有文件路径

    struct ThreadParameter
    {
        CString file_path_name;
    };
    
    
    
    //注意这里调用时候,路径要加上\*.*"  或者 /*.*
      vector<ThreadParameter> vec_filepaths; 
    //CString strDirPath = _T("E:\google-cpp-style\TestEn_DecryptDLL_v1.0\TestEn_DecryptDLL\data\multithread\plain\*.*");
    CString strDirPath = _T("data/multithread/plain/*.*");
    vec_filepaths.clear();

    GetFiles(strDirPath, vec_filepaths);

    for (int i = 0; i < vec_filepaths.size(); ++i)
    {
    OutputDebugString(vec_filepaths[i].file_path_name);
    OutputDebugString(_T(
    " "));

    }
    BOOL CTestEn_DecryptDLLDlg::GetFiles(CString strPath, vector<ThreadParameter> &vec_filepaths)
    {
    
        CFileFind finder;
        BOOL bWorking = finder.FindFile(strPath);
        while (bWorking)
        {
            //如果还有文件存在就继续执行
            bWorking = finder.FindNextFile();
    
            if (finder.IsDots()) //. 或者..
            {
                bWorking = finder.FindNextFile();
                continue;
            }
    
            //一般文件及文件夹
            BOOL bisDir = finder.IsDirectory();
            if (bisDir)
            {
                //文件夹
                CString repath = finder.GetFilePath();
                GetFiles(strPath, vec_filepaths);
            }
            else
            {
                //文件
                ThreadParameter tp;
                tp.file_path_name = finder.GetFilePath();
                vec_filepaths.push_back(tp);
            }
        }
        finder.Close();
        return 1;
    }
  • 相关阅读:
    00-03.kaliLinux-vi粘贴复制功能配置
    00-02.kaliLinux-配置SSH服务
    00-01.Kali Linux 2020.1修改root用户密码
    Web设计色彩(转载)
    Inno Setup区段之Language篇
    Inno Setup区段之Setup篇
    IE无法获取到input框的值
    Inno Setup之常量篇
    Inno Setup之概念篇
    网络不通排查
  • 原文地址:https://www.cnblogs.com/XiHua/p/5019555.html
Copyright © 2011-2022 走看看