<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Em sex., 1 de ago. de 2025, 17:54, James Richters via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org" rel="noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">fpc-pascal@lists.freepascal.org</a>> escreveu:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif">Thank you for the great suggestions!<span>  </span>I did not know I could have a memory version of the <span>ini</span> file. <br>that sounds like a better solution than what I am doing.<span>  </span>Right now I am reading in all the <span>ini</span> settings and putting them into variables like <br><span>Ini_myvariable</span><br><br>then I use those as needed.. then write them all out, but if I am understanding it correctly could I just use the memory version of the <span>ini</span> file directly?<br><br>It seems like that would be much easier and also solve the issues.<br><br>James</span></p></div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto"><a href="https://github.com/fpc/FPCSource/blob/main/packages/fcl-base/src/inifiles.pp" rel="noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">https://github.com/fpc/FPCSource/blob/main/packages/fcl-base/src/inifiles.pp</a></div><div dir="auto"><br></div><div dir="auto">To try to resolve your issue you should use TMemIniFile and invoke Rename() before freeing the TMemIniFile (or invoking UpdateFile explicitly) to save to the temporary file.</div><div dir="auto"><br></div><div dir="auto"></div><div dir="auto">TMemIniFile is just TIniFile with some extra methods and with CacheUpdates defaulting to True. They parse the whole ini file in the constructor, so values are always read from memory.</div><div dir="auto"><br></div><div dir="auto">Regards,</div><div dir="auto">Flávio </div><div dir="auto"><br></div><div dir="auto">P.S. Although these classes are meant for compatibility with Delphi/Windows, maybe they should provide extra methods with correct exception handling and "atomic" saving with temporary file?</div><div dir="auto">Or maybe someone can recommend alternatives?</div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
</blockquote></div></div></div>