Hi
I have to log some events to a text file with C/AL.
I write this proc:
GetKIRSetup;
IF EXISTS(KIRSetup."Log Filename") THEN
LogFile.OPEN(KIRSetup."Log Filename")
ELSE
LogFile.CREATE(KIRSetup."Log Filename");
LogFile.CREATEOUTSTREAM(LogStream);
LogStream.WRITETEXT(FORMAT(0D)+Szoveg);
LogFile.CLOSE;
LogFile and LogStream are local variables.
When the file doesn't exists, this procedure creates it, but if it exists, Navision gives me an error (access denied).
File attributes, permissions are ok.
What am I doing wrong? (or how to append to text file?)
Comments
If you want append:
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
maybe it is is easier to use a single instance codeunit instead of reopening the file ... but therefor you need navi 3.7 !
Your error appeared because you had to set
before you open file.
Furthermore, try this code(without OutStream object type):
Hope it helps!
I merged your solutions, and it works