procedure TForm1.ButtonClick(Sender: TObject);
begin
  if OpenPictureDialog1.Execute then
   showmessage(ExtractFileDir(OpenPictureDialog1.FileName));
end;

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    if Openpicturedialog1.Execute then
      button1.Caption:=OpenpictureDialog1.FileName;
    end;
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    if Openpicturedialog1.Execute then
      Showmessage(ExtractFileDir(OpenpictureDialog1.FileName));
    end; 
      

  3.   

    function ExtractFileDir(const FileName: string): string;DescriptionThe resulting string is a directory name suitable for passing to the CreateDir, GetCurrentDir, RemoveDir, and SetCurrentDir functions. This string is empty if FileName contains no drive and directory parts.
      

  4.   

    ExtractFileDir(OpenPictureDialog.filename);
      

  5.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    if opendialog1.Execute then
    edit1.Text :=extractfiledir(opendialog1.FileName );//文件路径
    edit2.Text :=extractfilename(opendialog1.FileName );//文件名
    end;