Lazarus中文社区

 找回密码
 立即注册(注册审核可向QQ群索取)

QQ登录

只需一步,快速开始

Lazarus IDE and 组件 下载地址版权申明
查看: 3122|回复: 0

Lazarus写入文件和目录到列表框的方法-DEMO

[复制链接]

该用户从未签到

发表于 2010-7-23 14:40:00 | 显示全部楼层 |阅读模式
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3. //   Searcher: TFileReader;
  4.   Info : TSearchRec;
  5.   Count : Longint;
  6.   app: string;
  7. begin
  8.      Count:=0;
  9.      //se volessi leggere la cartella corrente basterebbe *
  10.      If FindFirst ('c:\*',faAnyFile and faDirectory,Info)=0 then
  11.        begin
  12.        Repeat
  13.          Inc(Count);
  14.          With Info do
  15.            begin
  16.            If (Attr and faDirectory) = faDirectory then
  17.              Form1.Lista_File.Items.Add('Dir : ' + Name + ' dimensione: ' + IntToStr(Size))
  18.            else
  19.             Form1.Lista_File.Items.Add('File : ' + Name + ' dimensione: ' + IntToStr(Size));
  20.          end;
  21.        Until FindNext(info)<>0;
  22.        end;
  23.      FindClose(Info);
  24.      //Writeln ('Finished search. Found ',Count,' matches');
  25.      Form1.Lista_File.Items.Add('Finished search. Found ' + IntToStr(Count) + ' matches');
  26. end;
  27. //to control the drive
  28. procedure TForm1.Button2Click(Sender: TObject);
  29. begin
  30.      if DirectoryExists('C:')=TRUE then
  31.      begin
  32.           ShowMessage('Il drive C: esiste!');
  33.      end;
  34.      if DirectoryExists('E:')=TRUE then
  35.      begin
  36.           ShowMessage('Il drive E: esiste!');
  37.      end;
  38. end;     
复制代码
回复

使用道具 举报

*滑块验证:

本版积分规则

QQ|手机版|小黑屋|Lazarus中国|Lazarus中文社区 ( 鄂ICP备16006501号-1 )

GMT+8, 2025-5-3 12:45 , Processed in 0.025543 second(s), 10 queries , Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表