在C言语里,怎样搜索一个文件夹里有哪些子文件夹,谢谢

ITbirdman 2009-01-04 05:48:33
在C言语里,怎样搜索一个文件夹里有哪些子文件夹,谢谢
...全文
133 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
zzzlll1983 2009-01-06
  • 打赏
  • 举报
回复
学习
submarine2007 2009-01-05
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 ITbirdman 的回复:]
能不能给出一个实例说明下了
[/Quote]

unix环境高级编程的第4章有个例子可以参考
selooloo 2009-01-05
  • 打赏
  • 举报
回复
system("dir/a")
踏岸寻柳 2009-01-05
  • 打赏
  • 举报
回复
试一试readdir
Lovegarfield 2009-01-05
  • 打赏
  • 举报
回复
CFile类,不过要支持MFC
lsd1025 2009-01-05
  • 打赏
  • 举报
回复

//清空文件夹中的文件
BOOL DeleteFolderFile(CString FolderName)
{
char strTemp[100];
CString m_strFolder;
::GetCurrentDirectory(sizeof(strTemp),strTemp);
m_strFolder =strTemp;
m_strFolder =m_strFolder +"//" + FolderName +"//";
CFileFind finder;
CString strFindFolder = m_strFolder + "*.*";
BOOL bWorking = finder.FindFile(strFindFolder,0);
while(bWorking)
{
bWorking = finder.FindNextFile();
if(finder.IsDirectory() || finder.IsDots())
continue; // Not a file 这里说明是文件夹
CString strFoundFile = finder.GetFilePath();
::DeleteFile(strFoundFile);
}
finder.Close();

return TRUE;
}
星羽 2009-01-05
  • 打赏
  • 举报
回复
findfirst
findnext
codesnail 2009-01-05
  • 打赏
  • 举报
回复
递归
waizqfor 2009-01-04
  • 打赏
  • 举报
回复
http://www.vckbase.com/document/viewdoc/?id=449
多线程查找的例子 估计能有用
ITbirdman 2009-01-04
  • 打赏
  • 举报
回复
能不能给出一个实例说明下了
submarine2007 2009-01-04
  • 打赏
  • 举报
回复
如何访问一个目录取决于操作系统的接口

所以你要先知道操作系统的接口, 然后, 访问你指定的目录, 读取其中的文件, 当遇到目录时, 再打开这个目录, 如此类推, 一般都是用递归的方法来实现的

70,037

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧