if fileExists('C:\yyp\yyp.txt')=true then begin {文件存在}; end else begin {文件不存在的处理} end;
if fileExists('C:\yyp\yyp.txt') then begin {文件存在}; end else begin {文件不存在的处理} end;
//当button被选中,由Edit指定的文件名在当前路径和Windows路径中被查找。 procedure TForm1.Button1Click(Sender:TObject); var buffer:array[0..255] of char; FileToFind:string; begin GetWindowsDirectory(buffer,SizeOf(buffer)); FileToFind:=FileSearch(Edit1.Text,GetCurrentDir+';'+buffer); if FileToFind='' then showmessage('Couldn''tfind'+Edit1.text+'.') else showmessage('Found'+FileToFind+'.'); end;
begin
{文件存在};
end
else
begin
{文件不存在的处理}
end;
begin
{文件存在};
end
else
begin
{文件不存在的处理}
end;
procedure TForm1.Button1Click(Sender:TObject);
var
buffer:array[0..255] of char;
FileToFind:string;
begin
GetWindowsDirectory(buffer,SizeOf(buffer));
FileToFind:=FileSearch(Edit1.Text,GetCurrentDir+';'+buffer);
if FileToFind='' then
showmessage('Couldn''tfind'+Edit1.text+'.')
else
showmessage('Found'+FileToFind+'.');
end;