社区
Delphi
帖子详情
请教怎么查找文件
xiaofeixia110
2003-10-15 04:21:59
大家好,我刚才学DELPHI不久。现在我想问问怎么查找硬盘里的某一指定文件
另久我不知如何判断是否目录还是文件。大家帮帮我,谢谢
我看过网上的文章。实现不了。
...全文
80
2
打赏
收藏
请教怎么查找文件
大家好,我刚才学DELPHI不久。现在我想问问怎么查找硬盘里的某一指定文件 另久我不知如何判断是否目录还是文件。大家帮帮我,谢谢 我看过网上的文章。实现不了。
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
2 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
pankun
2003-10-16
打赏
举报
回复
是查找某一文件是否存在,还是查找文件啊?
下面是查找指定文件的例子.
procedure findall(disk,path: String; var fileresult: Tstrings);
var
fpath: String;
fs: TsearchRec;
begin
fpath:=disk+path+'\*.*';
if findfirst(fpath,faAnyFile,fs)=0 then
begin
if (fs.Name<>'.')and(fs.Name<>'..') then
if (fs.Attr and faDirectory)=faDirectory then
findall(disk,path+'\'+fs.Name,fileresult)
else
fileresult.add(disk+strpas(strupper(pchar(path)))+'\'+strpas(
strupper(pchar(fs.Name)))+'('+inttostr(fs.Size)+')');
while findnext(fs)=0 do
begin
if (fs.Name<>'.')and(fs.Name<>'..') then
if (fs.Attr and faDirectory)=faDirectory then
findall(disk,path+'\'+fs.Name,fileresult)
else
fileresult.add(disk+strpas(strupper(pchar(path)))+'\'+str
pas(strupper(pchar(fs.Name)))+'('+inttostr(fs.Size)+')');
end;
end;
findclose(fs);
end;
procedure DoSearchFile(Path: string; Files: TStrings = nil);
var
Info: TSearchRec;
procedure ProcessAFile(FileName: string);
begin
if Assigned(PnlPanel) then
PnlPanel.Caption := FileName;
Label2.Caption := FileName;
end;
function IsDir: Boolean;
begin
with Info do
Result := (Name <> '.') and (Name <> '..') and ((attr and fadirectory) = fadirectory);
end;
function IsFile: Boolean;
begin
Result := not ((Info.Attr and faDirectory) = faDirectory);
end;
begin
Path := IncludeTrailingBackslash(Path);
try
if FindFirst(Path + '*.*', faAnyFile, Info) = 0 then
if IsFile then
ProcessAFile(Path + Info.Name)
else if IsDir then DoSearchFile(Path + Info.Name);
while FindNext(Info) = 0 do
begin
if IsDir then
DoSearchFile(Path + Info.Name)
else if IsFile then
ProcessAFile(Path + Info.Name);
Application.ProcessMessages;
if QuitFlag then Break;
Sleep(100);
end;
finally
FindClose(Info);
end;
end;
xinglinshu
2003-10-16
打赏
举报
回复
用FileExists(const FileName: string): Boolean;查
websocket连接MQTT服务器所用的js文件——mqtt.js和mqtt.min.js
mqtt.js库,下载后可以用找我要源码和压缩文件(mqtt.min.js),有问题随时
请教
win7打印机共享和文件一键设置
共享需要很多 设置,
请教
别人还不教,网上教程试了还不行,很着急,后来找了这个批处理文件,一键搞定,万事无忧,直接上传。
Android Studio 合并module到统一文件夹的方法
在同一项目中,引用了多个module,长短不一的命名显得比较乱, 这里想把引入的module放到统一的目录,方便管理 在项目中新建一个文件夹 1、先正常导入module到项目中 2、把导入的module拖入...经过
请教
同事,查找资料最
python通过路径找文件_Python寻找路径和
查找文件
路径的示例
怎么python系统的查找路径要是爱你爱的少些,话就可以说的多些了。简?奥斯汀⒈单击开始,在搜索框输入cmd,然后回车,就会出现命令行界面框后...python实现查找某个路径下所有的文件是否包#coding=utf-8 import os i...
python找不到文件数据_python,_Pyhton读取文件时为什么找不到文件?,python - phpStudy...
我想打开一个txt格式的文件并且想把每一行都输出出来,但是报错说:找不到文件,
请教
是什么问题。注:我看书说要把文件放在python所在的文件夹下面,这样做了发现并没有什么效果。相关阅读:github的restful API后台...
Delphi
5,388
社区成员
262,730
社区内容
发帖
与我相关
我的任务
Delphi
Delphi 开发及应用
复制链接
扫一扫
分享
社区描述
Delphi 开发及应用
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章