批量检测文件路径是否存在

s8yyc 2011-03-05 05:07:27
检测文件路径是用FileExists

那如何批量进行检测呢

假如现在有个listbox,每行都是文件的路径

要实现的功能:
文件都存在showmessage('1')
只要有一个文件不存在就showmessage('2')


要具体代码~~
...全文
71 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Oraclers 2011-03-05
  • 打赏
  • 举报
回复
var
i:integer;
IsExists :boolean;
begin
IsExists := False;
for i:=0 to listbox1.Items.Count-1 do
if Fileexists(Trim(listbox1.Items[i])) then
IsExists := True
else begin
IsExists := False;
Break;
end;
if IsExists then
showmessage('1')
else
showmessage('2');
end;

s8yyc 2011-03-05
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 bdmh 的回复:]
循环list,对每个item调用FileExists
[/Quote]

这我知道,可是写出来有问题

var
i:integer;

begin
for i:=0 to listbox1.Items.Count-1 do
if Fileexists(Trim(listbox1.Items[i])) then
showmessage('1')
else
showmessage('2');
end;


listbox里有几行,showmessage('1')就执行了几遍
我想让showmessage只执行一次
sforiz 2011-03-05
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 bdmh 的回复:]
循环list,对每个item调用FileExists
[/Quote]

up
或者写一个过程
bdmh 2011-03-05
  • 打赏
  • 举报
回复
循环list,对每个item调用FileExists

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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