以下是源码,实现的功能是把Filelistbox1(文件列表)所指的目录下
的所有TXT文件放入listbox1里,等候进一步处理,时间仓促,功能不强,
如有BUG请指出。
procedure Tmainform.FormCreate(Sender: TObject);
var
i,long:integer;
strvar:string;
txtfilenumber:integer;{存放目录下TXT文件的数目 }
filenumber: integer;{存放目录下总的文件数目 }begin
listbox1.Clear; imagepoint:=0;
imagefilenumber:=0;
filelistbox1.directory:='c:\newsuccmis';
filelistbox1.Update;
filenumber:=filelistbox1.Items.Count;
for i:=0 to filenumber-1 do
begin
{判断是否含有为图像文件}
strvar:=filelistbox1.Items[i];
long:=length(strvar);if long>4 then
beginif (strvar[long-3]='.') and ((strvar[long-2]='t')or(strvar[long-2]='T')) and ((strvar[long-1]='x') OR(strvar[long-1]='X'))and ((strvar[long]='t')OR (strvar[long]='T')) then
beginlistbox1.Items.Add(strvar);
txtfilenumber:=txtfilenumber+1;
end;
end;end;end;
的所有TXT文件放入listbox1里,等候进一步处理,时间仓促,功能不强,
如有BUG请指出。
procedure Tmainform.FormCreate(Sender: TObject);
var
i,long:integer;
strvar:string;
txtfilenumber:integer;{存放目录下TXT文件的数目 }
filenumber: integer;{存放目录下总的文件数目 }begin
listbox1.Clear; imagepoint:=0;
imagefilenumber:=0;
filelistbox1.directory:='c:\newsuccmis';
filelistbox1.Update;
filenumber:=filelistbox1.Items.Count;
for i:=0 to filenumber-1 do
begin
{判断是否含有为图像文件}
strvar:=filelistbox1.Items[i];
long:=length(strvar);if long>4 then
beginif (strvar[long-3]='.') and ((strvar[long-2]='t')or(strvar[long-2]='T')) and ((strvar[long-1]='x') OR(strvar[long-1]='X'))and ((strvar[long]='t')OR (strvar[long]='T')) then
beginlistbox1.Items.Add(strvar);
txtfilenumber:=txtfilenumber+1;
end;
end;end;end;
解决方案 »
- dbgrid.columns下的add all fields为灰色不可用
- 调试时如何看嵌套结构中的变量
- 郁闷完了!Delphi8.0
- 向Interbase中的一个表插入了一条数据,有一个DBGrid和这个表相连,DBGrid的DataSource是和SimpleDataSet连的,为什么SimpleDataSet.Refr
- ★★★★★★★★★★★★★★散分推荐些好东西,不是作广告★★★★★★★★★★★★★★
- 各位程序员 有那位开发过字典的供点经验吗!
- 请问在delphi中怎么控制IIS?急!
- 有谁知道 ptoc 怎么用?
- 从那里可以找到编译器或者转换器的原码?
- 高手来过招:数据恢复
- 各位老大,给一个VCL控件吧,有没有,带有动画的SPEEDBUTTON,像OICQ里的那种
- WEB数据库的问题
在窗体中搞一个ListVeiw、ListImage及Button。procedure TForm1.Button1Click(Sender: TObject);
var
SearchRec : TSearchRec;
Path : String;
Attr : integer;
Found : integer;
begin
Path := 'c:\*.*';
Attr := faAnyFile;
Found := FindFirst(Path, Attr, SearchRec);
while Found = 0 do
begin
ListView1.Items.Add;
ListView1.Items[ListView1.Items.Count-1].Caption := (SearchRec.Name);
Found := FindNext(SearchRec);
end;
FindClose(SearchRec);
end; 上面的例子演示乐加入到treeview里面。您可以把treeview换成一个stringlist对象,然后遍历此对象中的元素就可以乐。
如:
for I := 1 to sl.items.count-1 do begin
if FileExists(sl.items[I]) then //干你想干的事情
end;
procedure Tmainform.FormCreate(Sender: TObject);
var
i,long:integer;
strvar:string;
txtfilenumber:integer;{存放目录下TXT文件的数目 }
filenumber: integer;{存放目录下总的文件数目 }begin
listbox1.Clear;
txtfilenumber:=0;
filelistbox1.directory:='c:\newsuccmis';
filelistbox1.Update;
filenumber:=filelistbox1.Items.Count;
for i:=0 to filenumber-1 do
begin
{判断是否含有为TXT文件}
strvar:=filelistbox1.Items[i];
long:=length(strvar);
if long>4 then
begin
if (strvar[long-3]='.') and ((strvar[long-2]='t')or(strvar[long-2]
='T')) and ((strvar[long-1]='x') OR(strvar[long-1]='X'))and ((strvar
[long]='t')OR (strvar[long]='T')) then
begin
listbox1.Items.Add(strvar);
txtfilenumber:=txtfilenumber+1;
end;
end;
end;
end;
filelistbox??还是
78product(神剑)
是方法好一些,
但我还想知道
Found := FindNext(SearchRec);按什么排序,??