var
OldName,NewName: string;
begin
OldName := 'c:\temp\Old.txt';
NewName := 'c:\temp\New.txt';
if RenameFile(OldName,NewName) then
ShowMessage('改名成功!');
//也可以:
SetCurrentDir('c:\temp');
OldName := 'Old.txt';
NewName := 'New.txt';
if RenameFile(OldName,NewName) then
ShowMessage('改名成功!');
end;
=====================
function RenameFile(const OldName, NewName: string): Boolean;
begin
{$IFDEF MSWINDOWS}
Result := MoveFile(PChar(OldName), PChar(NewName));
{$ENDIF}
{$IFDEF LINUX}
Result := __rename(PChar(OldName), PChar(NewName)) = 0;
{$ENDIF}
end;