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 .
Tengos two codes one is this :
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;
This goes to perfection but do not want to use the component Classes for the program does not weigh much .
Also I have this :
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;
Other 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 > 0) do
begin
Readfile(hFile, datafile, BUFF_SIZE, dwread, nil);
codigofinal := codigofinal + datafile;
end;
Result := codigofinal;
end;
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.
Someone can help me?
finalarchivo : = + lineasleyendo finaldearchivo
is not valid Delphi syntax. If you want help with your code, post your real code. We can't debug code you make up as you go, because you could change the real problem while you're making it up. – Ken White Nov 14 '13 at 16:41