procedure MyRename(const OldName: String); var tmp: String; i: Integer; begin for i:=Length(Oldname) downto 1 do if OldName[i]='.' then Break; if i<1 then Exit; tmp := Copy(OldName, 1, i-1); RenameFile(OldName, tmp); end;
procedure TForm1.Button1Click(Sender: TObject); begin if opendialog1.Execute then Edit1.Text:=ExtractFileName(OpenDialog1.FileName); Edit2.Text:=copy(edit1.Text, 1, Length(Edit1.Text) - 4); end;
然后用COPY()
var
tmp: String;
i: Integer;
begin
for i:=Length(Oldname) downto 1 do
if OldName[i]='.' then Break;
if i<1 then Exit;
tmp := Copy(OldName, 1, i-1);
RenameFile(OldName, tmp);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if opendialog1.Execute then
Edit1.Text:=ExtractFileName(OpenDialog1.FileName);
Edit2.Text:=copy(edit1.Text, 1, Length(Edit1.Text) - 4);
end;