<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hi,</p>
    <p>I want to achieve this:</p>
    <p>If file with given name already exists then open it for append
      else create new one and open it for append.</p>
    <p>I use something like:</p>
    <p>  FileName:='FileName'+formatdatetime('yymmdd',date)+'.log';<br>
        if FileExists(FileName) then F:=FileOpen(FileName,
      fmOpenWrite+fmShareDenyWrite) else F:=FileCreate(FileName);<br>
        FileSeek(F, 0, 2); //... 0 bytes from the end of the file<br>
        FileWrite(F, Pointer(s)^, length(s));<br>
        FileClose(F);</p>
    <p>or:</p>
    <p>  if FileExists(FileName) then<br>
          FS := TFileStream.Create(FileName,
      fmOpenWrite+fmShareDenyWrite)<br>
        else<br>
          FS := TFileStream.Create(FileName, fmCreate+fmShareDenyWrite);<br>
        FS.Seek(0, soEnd);<br>
        FS.Write(s[1], Length(s));<br>
        FS.Free;<br>
    </p>
    <p>Is there way how to achieve this using one-line without checking
      FileExists ? i.e.:<br>
      resulting efect like when using on Windows CreateFile(FileName,
      GENERIC_WRITE, FILE_SHARE_READ, <b class="">OPEN_ALWAYS,</b><span
        class=""> ...)</span><b class=""><br>
        CreationDisposition =  OPEN_ALWAYS - Opens a file, always if
        exists else create new one.<br>
        If the specified file exists, the function succeeds and the
        last-error code is set to ERROR_ALREADY_EXISTS (183).<br>
        If the specified file does not exist and is a valid path to a
        writable location, the function creates a file and the
        last-error code is set to zero.</b></p>
    <p><span class="">L.<br>
      </span><b class=""></b></p>
  </body>
</html>