怎样将一个LOG文件保存到指定的目录下?(30分)

K

kanble

Unregistered / Unconfirmed
GUEST, unregistred user!
Msg.Lines.SaveToFile('log' + FormatDateTime('yymmddhhnnss', now) +'.ini');
上面生成的文件只是保存在运行EXE的目录下,但我想把LOG文件保存到其它目录中,请问各位有何好的建议?
 
DstPath := 'C:/Windows/';
Msg.Lines.SaveToFile(DstPath + 'log' + FormatDateTime('yymmddhhnnss', now) +'.ini');
不就保存到 DstPath 目录下了?
 
按BETA的方法是可以成功的,我会给分你的,但不满足我的要求,我的路径是从INI文件中取
出来的值,即DstPath的值是从INI文件中得到,所以运行时会报错,不能建立INI文件
.朋友,再麻烦一下你,谢谢!
 
用流操作可以实现吗?
 
uses IniFiles;
var
s: TIniFile;
begin
s := TIniFile.Create;
DstPath := s.ReadString('section', 'DestPath', ExtractFilePath(Application.ExeName));
s.Free;
Msg.Lines.SaveToFile(DstPath + 'log' + FormatDateTime('yymmddhhnnss', now) +'.ini');
end;
 
BETA,辛苦你了,是INI文件目录大小写的问题,已解决.THANKS!
 
不客气:)
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
920
DelphiTeacher的专栏
D
顶部