在DELPHI中如何获得文件路径

2025-03-03 17:14:27
推荐回答(1个)
回答1:

begin
edit1.text:=extractfiledir(application.ExeName);
edit1.text:=extractfilepath(application.ExeName);
这个是获取自身目录的函数,两函数不同的是一个路径后带有"\",一个没有

如果要获取打开文件的路径,使用opendialog控件(在dialogs控件组下):
begin
if opendialog1.Execute then
edit1.text:=opendialog1.FileName ;
//在文本框显示路径
end;