title: I cannot delete a just created textfile
body: <p>When I create a textfile, next copy it to another directory and then try to delete the original, it won't work, because the programa keeps the file locked. 
  Before deleting the file, I set the file-attribute to 'normal'like this:</p>
  
  <pre><code>SetFileAttributes((pchar('C:\test')),FILE_ATTRIBUTE_NORMAL);
  </code></pre>
  
  <p>I cannot find any simple solution to resolve this.
  I create the file like this:</p>
  
  <pre><code>    bestand:= tstringlist.Create;
      try
        r:= FindFirst('test.*', faAnyFile, Res);
        try
         EOFound:= False;
          if (r = 0) then
            while not EOFound do
              begin
                bestand.Add(res.Name);
                EOFound:= FindNext(Res) &lt;&gt; 0;
              end;
        finally
          FindClose(Res);
        end;
      finally
        bestand.SaveToFile('C:\test');
        bestand.Free;
      end;
  </code></pre>
  
  <p>The same problem occurs when only reading the file like this:</p>
  
  <pre><code>AssignFile(Txt,TmpBest);
  Reset(Txt);
    while not Eof(Txt) do
       begin
          Readln(Txt, s);
          L.Items.add.caption:=s;
       end;
    CloseFile(Txt);
  </code></pre>
  
  <p>Later, I set the file attributes to 'Normal' and try to delete the file:</p>
  
  <pre><code>  if CopyFile(pchar(file-org), pchar(file-dest), false) then 
      begin 
        SetFileAttributes(pchar(file-org),FILE_ATTRIBUTE_NORMAL); 
        if not DeleteFile(file-org) then 
          showmessage('delete ' + file-org + ' failed!'); 
  </code></pre>
  
  <p>where file-org is file Txt/TmpBest from the description above. 
  I must say: I am not a Delphi programmer; I write in COBOL, but 'inherited' this Delphi-program from a former collegue and need to add some changes to it.</p>