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

    示例代码如下:

    注意:第一次找到的是.    表示本目录, 第二次找到的是..    表示上级目录,然后才找相应的文件和文件夹,按名称排序返回

    void BrowseFile(CString strFile )
    {
    	CFileFind ff;
    	CString szDir = strFile;
    
    	if(szDir.Right(1) != "\\")
    		szDir += "\\";
    
    	szDir += "*.*";
    
    	BOOL res = ff.FindFile(szDir);//找image目录下的文件
    	
    	while(res)
    	{
    		res = ff.FindNextFile();
    		CString strPath = ff.GetFilePath();
    		if(ff.IsDirectory() && !ff.IsDots())
    		{
    			//如果是一个子目录,用递归继续往深一层找
    			CString strPath = ff.GetFilePath();
    			CString strTitle = ff.GetFileTitle();
    			//put your code here
    			BrowseFile(strPath);
    		}
    		else if(!ff.IsDirectory() && !ff.IsDots())
    		{
    			//显示当前访问的文件
    			CString strPath;
    			CString strTitle;
    			strPath = ff.GetFilePath();
    			//put your code here
    		}
    	}
    	ff.Close();//关闭
    }
  • 相关阅读:
    洛谷 PT2 First Step (ファーストステップ)
    Mask-D、绮梦与空谷幽兰
    僕らの手には何もないけど、
    魔都蹭课、观光、酱油记
    竞赛计划
    糖果
    点名
    数字对
    字符串哈希
    负环
  • 原文地址:https://www.cnblogs.com/sdqxcxh/p/1798945.html
Copyright © 2011-2022 走看看