1
I am trying to manipulate a text file on my system, in it will have to contain the name of the machine that the system is running. Only I can’t write in that file.
Ps: The purpose of this file is not to save the text, it is to have the text in it until the system is closed.
Below I will leave the code of how I create and try to write in the file, and only in the output of the system I close the file.
// Aqui o Autosad cria os arquivos de Controle de Usuário
for I := 1 to QuantUsuarios do
begin
NomeArq := DM.tbParamPASTA_BD.AsString+'\Controle'+IntToStr(I)+'.txt';
// Verificando se o arquivo existe
if not FileExists(nomeArq) then
begin
NomeMaquina := 'Controle: '+CompName; // CompName é uma função que pega o nome da maquina.
AssignFile(Arq, NomeArq);
Rewrite(Arq);
Writeln(Arq,NomeMaquina);
Break;
end;
if I >= QuantUsuarios then
begin
ShowMessage('Erro ao tentar Criar o arquivo de Controle!'+#13+'Acione o SUPORTE!!');
// Encerra o Sistema
DMl.db_AutoSad.Connected := False;
frmEntradaSistema.close;
end;
end;
this code I adapted from several websites I researched. if you have any other way of doing.
If you don’t want to save the file, just keep the data while running the program, you don’t need to create a file. You can keep the data, for example, in a Strignglist.
– Ricardo Alves Carvalho