unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
DirectoryList: TMemo;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
S: String;
i: Integer;
DirectoryList: TStringList;
function SlashSep(const Path, S: String): String;
begin
if AnsiLastChar(Path)^ <> '/' then
Result := Path + '/' + S
else
Result := Path + S;
end;
function ReadDirectoryNames(const ParentDirectory: string;const DirType:string;
DirectoryList: TStringList): Integer;
var
Status: Integer;
SearchRec: TSearchRec;
begin
Result := 0;
Status := FindFirst(SlashSep(ParentDirectory, DirType), faDirectory, SearchRec);
try
while Status = 0 do
begin
if ((SearchRec.Attr and faDirectory) = faDirectory) then
begin
if (SearchRec.Name <> '.') and (SearchRec.Name <> '..') then
begin
DirectoryList.Add(SearchRec.Name);
Inc(Result);
end;
end;
Status := FindNext(SearchRec);
end;
finally
SysUtils.FindClose(SearchRec);
end;
end;
begin
i:= ReadDirectoryNames('D:/系统/FCHWASystem/Modules/考勤数据导入','*.*',DirectoryList);
Edit1.Text := inttostr(i);
end;
end.
有时候运行回报错 Access vilation at adress 004295CC in module'project1.exe'write of adrress 0042910
这是怎么回事情,一会有好了,但是单击可执行文件,又会保同样的错误