请问一个获得路径的问题(50分)

  • 主题发起人 主题发起人 cavalise
  • 开始时间 开始时间
C

cavalise

Unregistered / Unconfirmed
GUEST, unregistred user!
请问各位高手,如何获得执行程序上一及的目录地址啊?
eg.
test.exe位于c:/temp/test/test.exe,test文件夹里还有ok.txt,temp目录里还有re.txt
程序中可以执行memo1.loadfromfile('ok.txt'),请问我要memo2里显示re.txt的内容,程序
应该如何处理?
 
memo1.loadfromfile('../re.txt')
 
momo2.loadfromfile('../re.txt')
 
请问各位高手,如何获得执行程序上一及的目录地址啊?
eg.
test.exe位于c:/temp/test/test.exe,test文件夹里还有ok.txt,temp目录里还有re文件夹,
re文件夹里有re.txt
程序中可以执行memo1.loadfromfile('ok.txt'),请问我要memo2里显示re.txt的内容,程序
应该如何处理?
 
var
dir:string;
dir:=copy(application.ExeName,1,pos(application.ExeName,'temp')+length('temp')-1);
memo1.loadfromfile(dir);
 
AppPath := ExtractFilePath(Application.ExeName);
上级目录为: AppPath + '../'
上上级为: AppPath + '../../'
 
S := Extractfilepath(paramstr(0));
S := Copy(S, 1, length(S) - 1);
S := Extractfilepath(S);
 

Similar threads

D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
903
DelphiTeacher的专栏
D
后退
顶部