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;
    }
  • 相关阅读:
    Qt数据库集成应用封装
    Qt个人研究进展
    Qt仿win7自动顶部最大化左侧右侧半屏效果
    Qt编写QUI皮肤生成器
    java定时任务
    进程间通信(java)--队列
    单例设计模式-java
    Java RMI
    远程调用方式概述
    IO模型-java版
  • 原文地址:https://www.cnblogs.com/XiHua/p/5019555.html
Copyright © 2011-2022 走看看