Access denied when renaming file lazarus / 21-General ---------------------------------------------------------------------- JJJ · 2021-02-05 08:46 I have a program that stores the log in the text file and it will be renamed in onclose event. If I start the software and close it immediately, I will receive an "access denied" error message the next time I close the program. If the time between opening and closing is long enough (>15 seconds) there will be no error message. Also if I don't "rename file" the program is closing normally. Any idea why "access denied" happening? ---------------------------------------------------------------------- MarkMLl · 2021-02-05 09:07 If you don't say what OS and platform you're using nobody will even try to suggest an answer. When you're talking about renaming it what exactly do you mean? is this in a script file or something you're trying to do manually? If it's inside the program then post your code and tell us EXACTLY what compiler etc. version you're using... are you explicitly closing the file before trying to rename it? MarkMLl ---------------------------------------------------------------------- jamie · 2021-02-05 21:58 In windows there is a feature to do delayed deletes and renames on files that are opened.. basically you need to ensure the file isn't opened before doing such things. ---------------------------------------------------------------------- winni · 2021-02-05 23:24 It is the same with Linux: The files are written into the buffers and they are flushed to the disk when the processor is not busy.  But there is no problem with renaming. But if the file is really huge this can take some time