When I start a program in the IDE, I use the following code to generate a log file. All of the paths are correct, checked with F8, but the log file is not output.
When I run the executable outside of the IDE, the log file is output properly.
Is there a setting somewhere in XE7 that prohibits this?
procedure LogProgram(const aEvent: String);
var
TheLogFileName, TheLogLine: String;
TheLogFile: TextFile;
TheDay, TheMonth, TheYear, TheHour, TheMinute, TheSecond,
TheMilliSecond: Word;
begin
TheLogFileName := Format('%s%d.log', [usPATH_LOGS, Trunc(Now)]);
AssignFile(TheLogFile, TheLogFileName);
if not FileExists(TheLogFileName) then
Rewrite(TheLogFile);
Append(TheLogFile);
DecodeDateTime(Now, TheYear, TheMonth, TheDay, TheHour, TheMinute, TheSecond,
TheMilliSecond);
TheLogLine := Format('%d-%d-%d: %d:%d:%d:%d%s%s', [TheYear, TheMonth, TheDay,
TheHour, TheMinute, TheSecond, TheMilliSecond, #9, aEvent]);
Writeln(TheLogFile, TheLogLine);
CloseFile(TheLogFile);
end;
I tried to output a file, using the above code, while a program was running in the Delphi XE7 IDE, expected a log (text) file and got no output. Running the same program outside of the IDE generates the log (text) file properly.
@fpiette I checked Windows Security and folder protection is not active.
@Andreas-Rejbrand I'm using relative paths. Paths are being calculated relative to the path of the executable
@SilverWarior I did not change anything in Delphi through menu Run->Parameters. There are no paths listed there.