我想点击一个按钮,然后查找“.txt”文件,文件名显示在一个 ListBox 或FileListBox里,然后点击 ListBox 或FileListBox里某个文件,然后把文件内容显示在下面的Memo里咋办?该怎么做呢?
很感谢!
很感谢!
解决方案 »
- 学习别人的程序中遇到的困难,关于查找,能帮我解释一下吗?谢谢
- RSA公钥密码算法的原理及实现
- 运行Dephi程序时,出现未发现ExceptionLog.dcu,不知是什么原因?
- FormatDateTime('YYYYMMDDHHMMSS',Now)这么精确到毫秒?
- 关于程序不能24小时运行的问题。
- 如何在QuickRep报表中打印出带有两位小数的数字(即是货币形式的数字).
- TClientDataset.ApplyUpdate 的使用问题 (在线等候)
- 数据库程序处理数据的方法问题
- 请问各位大侠李维什么时候到南京演讲
- 重要问题,高手请进!
- 本人的为难之处!!!!!
- 请问word文档或powerPOint文档,如何读取之中的超级联接
begin
if FindFirst("c:\*.txt", faAnyFile, sr) = 0 then
repeat
ListBox.Items.Add(sr.Name);
until FindNext(sr) <> 0;
FindClose(sr);
end;
FileListBox1->Mask="*.txt";
FileListBox1->Directory = "YourDirectory";然后在TFileListBox的事件中Memo1->Lines->LoadFromLie("the file name");
要找的并不只是.txt文件,还有其他文件,
我列出来只是示范一下,谢谢
westfly(西翔)的有点问题啊。
[Warning] tmouse.pas(7): Unit 'FileCtrl' is specific to a platform
[Error] tmouse.pas(144): Statement expected but 'VAR' found
[Error] tmouse.pas(148): Undeclared identifier: 'ListBox1'
[Error] tmouse.pas(148): Missing operator or semicolon
[Error] tmouse.pas(151): '.' expected but ';' found
[Warning] tmouse.pas(152): Text after final 'END.' - ignored by compiler
[Fatal Error] Project1.dpr(5): Could not compile used unit 'tmouse.pas'
function seekfile(const dir,fType:string;var flist:tstrings):boolean;
var
searchRec:TSearchRec;
fDir:string;
begin
fDir:=dir;
if pos('\',fdir)=length(fdir) then delete(fdir,length(fdir),1);
if not DirectoryExists(fdir) then
begin
result:=false;
end
else begin
FindFirst(fdir+'\*.*',faAnyfile,SearchRec);
repeat
if (SearChRec.Attr and faDirectory>0) then
begin
if (SearchRec.Name[1]<>'.') and (SearchRec.Name<>'RECYCLER') then
begin
if not seekfile(fdir+'\'+SearchRec.Name,ftype,flist) then
break;
end;
end//是目录
else begin
if fType='*.*' then
flist.Add(fdir+'\'+searchrec.Name);
if (fType[1]='*') and (fType[3]<>'*') then
if extractfileext(searchrec.Name)=fType then
flist.Add(fdir+'\'+searchrec.Name);
if Uppercase(fType)=Uppercase(searchrec.Name) then
flist.Add(fdir+'\'+searchrec.Name);
end;//是文件
until (FindNext(SearchREC)<>0);//repeat
result:=true;
end;//if dDirectoryExists(fdir) then
end;