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;
    }
  • 相关阅读:
    Go语言并发编程
    Go语言package
    大数据实践(十) Spark多种开发语言、与Hive集成
    大数据实践(九)--sqoop安装及基本操作
    Go语言错误处理
    Go语言接口
    Go语言面向对象
    数据库基础了解
    PL/SQL语句快捷输入设置
    重载操作符介绍
  • 原文地址:https://www.cnblogs.com/XiHua/p/5019555.html
Copyright © 2011-2022 走看看