对了,我用文件流这样分段可以发送大文件吗?
小的试过了,
var
MyFileStream:TFileStream;
//MyWriteStream:TMemoryStream;
TotalSize,ThisSize,LeftSize,SendSize:int64;
Mybuffer:array[0..1023]of byte;
PackCount:integer;
begin
if not OpenDialog1.Execute then
Exit;
MyFileStream:=TFileStream.Create(OpenDialog1.FileName,fmOpenRead);
//MyWriteStream:=TFileStream.Create;//内存流
//MyFileStream.Position:=0;//开头地方
MyFileStream.Seek(0,soFrombegin
ning);
TotalSize:=MyFileStream.Size;
SendSize:=0;
PackCount:=0;
while SendSize<totalSizedo
begin
if SendSize+1024<=TotalSize then
ThisSize:=1024
else
ThisSize:=TotalSize-sendSize;
MyFileStream.ReadBuffer(MyBuffer,ThisSize);
SysCtrlClass.SendData(Mybuffer,ThisSize);
SendSize:=SendSize+ThisSize;
Sleep(20);
Inc(PackCount);
end;
ShowMessage('total packs:'+IntToStr(PackCount));
end;