关于文件查找的问题(20分)

  • 主题发起人 主题发起人 stuwei
  • 开始时间 开始时间
S

stuwei

Unregistered / Unconfirmed
GUEST, unregistred user!
1.按以下方法查找指定目录下的文件,返回的f.name为什么为空呢?<br>procedure TForm1.Button1Click(Sender: TObject);<br>&nbsp;var f:TSearchRec;<br>begin<br>&nbsp;Findfirst('E:/TurboC3/',fahidden+fasysfile+faAnyfile,f);<br>&nbsp;memo1.Lines.Add(F.Name);<br>&nbsp; {while &nbsp;Findnext(F)=0 do<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; findnext(F);<br>&nbsp; &nbsp; memo1.Lines.Add(F.Name);<br>&nbsp; end &nbsp; &nbsp;<br>end;<br><br>
 
&nbsp; &nbsp;if FindFirst('E:/TurboC3/*.*',fahidden+fasysfile+faAnyfile,f) = 0 then<br>&nbsp; &nbsp; begin<br><br><br>{ &nbsp; &nbsp; &nbsp;repeat<br>&nbsp; &nbsp; &nbsp; &nbsp; memo1.Lines.Add(F.Name);<br>&nbsp; &nbsp; &nbsp; until FindNext(f) &lt;&gt; 0;}<br><br><br>// &nbsp; &nbsp; &nbsp;或者:<br><br><br>&nbsp; &nbsp; &nbsp; memo1.Lines.Add(F.Name);<br>&nbsp; &nbsp; &nbsp; While FindNext(f) = 0 do<br>&nbsp; &nbsp; &nbsp; &nbsp; memo1.Lines.Add(F.Name);<br><br><br>////请注意一定要FindClose否则会浪费资源.<br>&nbsp; &nbsp; &nbsp; FindClose(F);<br>&nbsp; &nbsp; end;<br>
 
procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; i:Integer;<br>&nbsp; f:TSearchRec;<br>begin<br>&nbsp; i:=Findfirst('E:/TurboC3/*.*',fahidden+fasysfile+faAnyfile,f);<br>&nbsp; while &nbsp;i=0 do<br>&nbsp; begin<br>&nbsp; &nbsp; memo1.Lines.Add(F.Name);<br>&nbsp; &nbsp; i:=findnext(F);<br>&nbsp; end;<br>end;
 

Similar threads

I
回复
0
查看
430
import
I
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
后退
顶部