该文件位于软件所在的目录中。我正在尝试将文本文件添加到备注框中。
procedure TForm4.FormCreate(Sender: TObject);
var
dir : string;
begin
Form4.Caption:='Abateri instrumente';
dir := GetCurrentDir;
Memo1.Lines.LoadFromFile(dir+'\abateri.txt');
end;发布于 2015-04-26 10:42:21
该文件位于软件所在的目录中。
在这种情况下,查看工作目录是错误的方法。没有理由让工作目录成为您的可执行文件所在的目录。你需要使用:
Dir := ExtractFilePath(ParamStr(0)); // the directory where the executable resides
TPath.Combine(Dir, FileName); // TPath is from the System.IOUtils unit当然,你的另一个问题是你弄错了你的文件名。该文件实际上名为abateri.txt.txt。
https://stackoverflow.com/questions/29875727
复制相似问题