【发布时间】:2009-05-07 20:04:12
【问题描述】:
(使用 Delphi 5)
我正在尝试使用以下代码打开一个日志文件:
// The result of this is:
// C:\Program Files\MyProgram\whatever\..\Blah\logs\mylog.log
fileName := ExtractFilePath(Application.ExeName) + '..\Blah\logs\mylog.log';
// The file exists check passes
if (FileExists(fileName)) then
begin
logs := TStringList.Create();
// An exception is thrown here: 'unable to open file'
logs.LoadFromFile(fileName);
end;
如果我将日志文件重新定位到 C:\mylog.log,则代码可以完美运行。我在想文件路径中的空格把事情搞砸了。有谁知道这是否是 Delphi 5 的正常行为?如果是,是否有转义空间或将路径转换为 windows 8.3 路径的功能?
【问题讨论】:
-
我暂时不得不离开这个问题,但是当我有机会时,我会检查错误是否是由实际写入日志的进程引起的。感谢大家迄今为止的帮助。
-
您确定文件没有被写入文件的进程锁定吗?
标签: delphi