Olá, segue abaixo um trecho de código onde implemento isto.
Foi um CTRL+C CTRL+V, porém concentre-se nas classes TFileStream e
TSTringStream.


function TFaxConexao.GetFax: string;
function PegarDia(const OReferencia: string): string;
begin
Result := Copy(OReferencia,7,8);
end;

var
referencia, caminho : string;
_stream : TFileStream;
_string : TStringStream;
begin
Result := '';
try
try
referencia := Self.HTTP.GetQueryString('REFERENCIA');
caminho := 'C:\mctcallserver\faxin\' + PegarDia(referencia) + '\' +
referencia;
GerarLog(Self.ClassName,14861456,Format('caminho: [%s]',[caminho]),
Self.FDistincao);
if (FileExists(caminho)) then
begin
try
csGetFax.Enter;
_stream := TFileStream.Create(caminho,fmOpenRead);
finally
csGetFax.Release;
end;
//--
_string := TStringStream.Create('');
_string.CopyFrom(_stream,0);
Result := _string.DataString;
end
else GerarLog(Self.ClassName,454514,'Arquivo não encontrado!',
Self.FDistincao);
except
on E : Exception do
begin
GerarLog(Self.ClassName,165445,MensagemErro(E),Self.FDistincao);
end;
end;
finally
if (Assigned(_stream))
then FreeAndNil(_stream);
if (Assigned(_string))
then FreeAndNil(_string);
end;
end;


[As partes desta mensagem que não continham texto foram removidas]

Reply via email to