怎样给文件重命名?D:\set.bmp又怎样只得到文件的set字符,不包括.bmp,呢?

解决方案 »

  1.   

    用pos()来查找"."的位置
    然后用COPY()
      

  2.   

    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;
      

  3.   


    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;
      

  4.   

    基本同意songzhiwei(song) 的看法
      

  5.   

    楼上二位,如果扩展名是.html怎么办?好像固定的写成4不太好吧