我想点击一个按钮,然后查找“.txt”文件,文件名显示在一个 ListBox 或FileListBox里,然后点击 ListBox 或FileListBox里某个文件,然后把文件内容显示在下面的Memo里咋办?该怎么做呢?
很感谢!
很感谢!
解决方案 »
- 请问怎样使TDBgrid控件的光标回到第1行去?
- 如何获取PageControl上某个标签的宽度和位置?
- 用Java作为服务端delphi作为客户端开发交流
- 大家来讨论一下,公司给员工的工资的依据:是能力还是对公司的贡献呢?
- ●●●●为了自己方便,也为大家方便,建立了一个DELPHI程序员QQ群:8194759●●●●
- 如何释放sndPlaySound占用的内存?
- 还是activeform。下载了,但不运行,怎么回事?
- StringGrid怎么做字体分色?
- 各位大虾,谁有无纸考试系统的资料?帮帮我吧.
- bcb 6 出来了! 能说说它和 DELPHI 6 有什么功能上的区别吗
- 本人的为难之处!!!!!
- 请问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;