procedure TForm1.Button1Click(Sender: TObject);
const
S = 'C:\Temp';
begin
if DirectoryExists(S) then
ShowMessage(S + '是目录')
else if FileExists(S) then
ShowMessage(S + '是文件')
else ShowMessage(S + '我怎么知道?')
end;
const
S = 'C:\Temp';
begin
if DirectoryExists(S) then
ShowMessage(S + '是目录')
else if FileExists(S) then
ShowMessage(S + '是文件')
else ShowMessage(S + '我怎么知道?')
end;
uses FileCtrl
///////////////////////////////////////////////////////////////////
判断是否为文件
///////////////////////////////////////////////////////////////////
比较长在这里:
http://www.codelphi.com/jsjn/read.asp?ano=663///////////////////////////////////////////////////////////////////
判断是否为目录
///////////////////////////////////////////////////////////////////
Function IsDir(IsDirPath: String): Boolean;
Var FileGetAttrValue: Integer;
Begin
{$IFDEF WIN32}
Result := DirectoryExists(IsDirPath);
Exit;
{$ENDIF}
FileGetAttrValue := FileGetAttr(IsDirPath);
If FileGetAttrValue = 16 Then
Begin
Result := True
End
Else
Begin
Result := False
End;
End;