title: Read text files in Delphi
body: <p>Hi I am having a problem running a function to read a text file the problem seems to be that my antivirus blocks my delphi console program because when I do for a visual form there is no problem .</p>
  
  <p>Tengos two codes one is this :</p>
  
  <pre><code>function LeerArchivox(const filename: TFileName): String;
  var
    List: TStringList;
  begin
  
    if (FileExists(filename)) then
    begin
  
      List := TStringList.Create;
      List.Loadfromfile(filename);
      Result := List.text;
      List.Free;
  
    end;
  
  end;
  </code></pre>
  
  <p>This goes to perfection but do not want to use the component Classes for the program does not weigh much .</p>
  
  <p>Also I have this :</p>
  
  <pre><code>function leerarchivo(filealeer: string): string;
  
  var
    abriendo: TextFile;
    lineasleyendo: string;
    finaldearchivo: string;
  
  begin
  
    finaldearchivo := '';
    AssignFile(abriendo, filealeer);
    Reset(abriendo);
  
    while not Eof(abriendo) do
    begin
      ReadLn(abriendo, lineasleyendo);
      finaldearchivo := finaldearchivo + lineasleyendo;
    end;
  
    CloseFile(abriendo);
  
    Result := finaldearchivo;
  
  end;
  </code></pre>
  
  <p>Other code.</p>
  
  <pre><code>function leerarchivo3(archivoaleer: string): string;
  
  const
    BUFF_SIZE = $8000;
  var
    dwread: LongWord;
    hFile: THandle;
    datafile: array [0 .. BUFF_SIZE - 1] of ansichar;
    codigofinal: string;
  
  begin
  
    codigofinal := '';
  
    hFile := CreateFile(PChar(archivoaleer), GENERIC_READ,
      FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING,
      FILE_ATTRIBUTE_READONLY, 0);
  
    SetFilePointer(hFile, 0, nil, FILE_BEGIN);
  
    Readfile(hFile, datafile, BUFF_SIZE, dwread, nil);
  
    while (dwread &gt; 0) do
    begin
      Readfile(hFile, datafile, BUFF_SIZE, dwread, nil);
      codigofinal := codigofinal + datafile;
    end;
  
    Result := codigofinal;
  
  end;
  </code></pre>
  
  <p>This is the problem because when I use my antivirus deletes it at the time , my question to other alternatives I have to read a text file without using Classes.</p>
  
  <p>Someone can help me?</p>