默认的重命名是这样的
MoveFile(PChar('C:1.txt'),PChar('C:ABC.txt'));
现在修改成这样的
__RenameFile('C:1.txt','abc');//重命名文件
//重命名文件 或文件夹
function __RenameFile(OldName:string;Title:string):Boolean;
var
NewName:string;
begin
NewName:= Format('%s%s%s',[ExtractFilePath(OldName),Title,ExtractFileExt(OldName)]);
Result:=MoveFile(PChar(OldName), PChar(NewName));
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if not __RenameFile('C: ree.txt','TreeView') then
Application.MessageBox('重命名文件失败','重命名',MB_ICONERROR);
end;