社区
C语言
帖子详情
谁有查找目录及子目录中所有文件的函数,将找到的文件放到TStrings。
ljhsoft
2002-04-05 10:12:23
我以前写了一个,使用替归的方法实现的,后来丢了手提电脑连函数也丢了。
TString * __fastcall GetFileFromDir(AnsiString strPathName)
{
//添加代码
}
...全文
99
1
打赏
收藏
谁有查找目录及子目录中所有文件的函数,将找到的文件放到TStrings。
我以前写了一个,使用替归的方法实现的,后来丢了手提电脑连函数也丢了。 TString * __fastcall GetFileFromDir(AnsiString strPathName) { //添加代码 }
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
1 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
ccnuxjg
2002-04-05
打赏
举报
回复
我上个月刚写的,送给你
void CNormalSearchDlg::OnOk()
{
// TODO: Add your control notification handler code here
int filenum = 0;
CString *filepath = 0;
filepath = new CString[1000];
FindTheExtFile( "D:\\temp", ".chm", filenum, filepath );
if( filepath!=NULL )
{
delete[]filepath;
filepath = NULL ;
}
}
//------------------------------------------------------------------------------------------------
// 函数名:FindTheExtFile
//
// function: search all the file in the Path that it's external name is Exname
// return: 所有的找到文件的完整路径--一个指针
// how to use: FindTheExtFile( "D:\\temp", ".chm", filenum, filepath );
// 作者: xiangjiangang
// Finish Date: 10:07 2002-3-29
//------------------------------------------------------------------------------------------------
BOOL CNormalSearchDlg::FindTheExtFile(const CString Path, const CString ExName, int &count, CString* OutPath)
{
CString tempPath[1000];
FindAllFile( Path, count, tempPath );
//在此过滤非扩展路径名的文件
int j = 0;
for( int i = 0; i < count; i ++ )
{
if( tempPath[i].Right( 4 ) == ExName )
{
OutPath[j] = tempPath[i];
j++;
}
}
count = j;
return TRUE;
}
//----------------------------------------------------------------------------------------
// 函数名:FindAllFile
//
// function: search all the file in the Path
// return: 所有的找到文件的完整路径--一个指针
// how to use: FindAllFile( Path, count, tempPath );
// 作者: xiangjiangang
// Finish Date: 10:07 2002-3-29
//----------------------------------------------------------------------------------------
BOOL CNormalSearchDlg::FindAllFile(const CString Path, int &count, CString *OutPath)
{
CFileFind tempFind;
char tempFileFind[200];
sprintf( tempFileFind, "%s\\*.*", Path );//先查找所有文件,这样不会遗漏子目录下面的文件
BOOL IsFinded=(BOOL)tempFind.FindFile(tempFileFind);
while(IsFinded)
{
IsFinded=(BOOL)tempFind.FindNextFile();
if(!tempFind.IsDots())//if the found file has the name "." or "..",是一真实路径
{
char foundFileName[200];
strcpy(foundFileName,tempFind.GetFileName().GetBuffer(200));//得到找到的文件的文件名或子路径
if(tempFind.IsDirectory())//如果是下层目录
{
char tempDir[200];
sprintf(tempDir,"%s\\%s",Path,foundFileName);
FindAllFile( tempDir, count, OutPath );//递归调用函数进行深度搜索
}
else
{
char tempFileName[200];
sprintf(tempFileName,"%s\\%s",Path,foundFileName);
OutPath[count] = tempFileName;//得到输出文件完整路径
count++;
}
}
}
tempFind.Close();
return TRUE;
}
怎么样才能遍历一个
目录
跟其下的
子
目录
(以二种方式实现
本文介绍如何遍历一个
目录
及其
子
目录
,包括计算特定类型
文件
的数量并将结果存储到List列表
中
,从而扩展到其他
文件
操作。
T
String
s的一些技巧
本文深入探讨了Delphi
中
T
String
s类的高级应用,包括CommaText、Delimiter与DelimitedText、Names与Values等属性的使用技巧,以及如何利用这些属性处理INI
文件
。
delphi遍历指定
目录
下指定类型
文件
的
函数
本文提供两个Delphi
函数
,用于遍历指定
目录
及其
子
目录
下的特定类型
文件
,并将
找到
的
文件
路径添加到T
String
s对象
中
。适用于快速
查找
并处理大量
文件
。
DELPHI获取某
目录
下的所有
文件
名
本文介绍使用DELPHI编程语言实现的两种方法来获取指定
目录
下的所有
文件
名,包括仅
查找
当前
目录
的
文件
和递归
查找
子
目录
中
的
文件
。
T
string
s 和 T
String
List 类 2
本文详细介绍了Delphi编程
中
T
String
s和T
String
Lists类的作用、特性及其实现原理,包括它们如何与组件交互,以及如何在代码
中
有效使用这些类来操作字符串列表。
C语言
70,038
社区成员
243,247
社区内容
发帖
与我相关
我的任务
C语言
C语言相关问题讨论
复制链接
扫一扫
分享
社区描述
C语言相关问题讨论
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章