这是我发送单个文件的编码。
procedure TForm1.IdTCPServerExecute(AThread: TIdPeerThread);
begin
...
try
...
AFileStream := TFileStream.Create(AFileName, fmOpenRead + fmShareDenyNone);
try
AThread.Connection.WriteStream(AFileStream, true, true);
finally
AFileStream.Free;
end;
except
AThread.Connection.WriteLn('N');
end;
AThread.Connection.Disconnect;
end;
如果我有多个文件要一次发送,请建议我怎么做?
是否可以使用一次阅读它
procedure TForm1.ReadImageFromServer(ACmd: string);
begin
with IdTCPClient1 do begin
...
AStreamSize := ReadInteger;
ReadStream(AMemStream, AStreamSize, false);
...
end;
end;