Z
zhoujian010
Unregistered / Unconfirmed
GUEST, unregistred user!
哪位高手看看下面的代码,错在哪里,为什么这个上传单元会出错?
unit UpLoadUnit;
interface
uses
Classes, IdTCPServer,IdGlobal,ComCtrls,SysUtils;
type
TUpLoadThread = class(TThread)
private
TheFileName:String;
TheFileSize:integer;
SysThread:TIdPeerThread;
protected
procedure Execute; override;
Public
constructor Create(AThread:TIdPeerThread;TFN:String;TheLen:integer);
destructor Destroy; override;
end;
implementation
uses APFUnit,server;
constructor TUpLoadThread.Create(AThread:TIdPeerThread;TFN:String;TheLen:integer);
begin
inherited Create(true);
TheFileName:=TFN;
TheFileSize:=TheLen;
SysThread:=AThread;
FreeOnTerminate:=true;
Suspended := false;
Priority:=tpIDLE;
end;
procedure TUpLoadThread.Execute;
var
SaveFStream:TFileStream;
begin
try
SaveFStream:=TFileStream.Create(TheFileName,fmCreate);
except
SysThread.Terminate;
self.Terminate;
exit;
end;
SaveFStream.Size:=0;
try
SysThread.Connection.ReadStream(SaveFStream,TheFileSize);//好像经常这儿出错,不知道如何改
except
SaveFStream.Free;
SysThread.Terminate;
self.Terminate;
exit;
end;
end;
destructor TUpLoadThread.Destroy;
begin
inherited destroy;
end;
end.
unit UpLoadUnit;
interface
uses
Classes, IdTCPServer,IdGlobal,ComCtrls,SysUtils;
type
TUpLoadThread = class(TThread)
private
TheFileName:String;
TheFileSize:integer;
SysThread:TIdPeerThread;
protected
procedure Execute; override;
Public
constructor Create(AThread:TIdPeerThread;TFN:String;TheLen:integer);
destructor Destroy; override;
end;
implementation
uses APFUnit,server;
constructor TUpLoadThread.Create(AThread:TIdPeerThread;TFN:String;TheLen:integer);
begin
inherited Create(true);
TheFileName:=TFN;
TheFileSize:=TheLen;
SysThread:=AThread;
FreeOnTerminate:=true;
Suspended := false;
Priority:=tpIDLE;
end;
procedure TUpLoadThread.Execute;
var
SaveFStream:TFileStream;
begin
try
SaveFStream:=TFileStream.Create(TheFileName,fmCreate);
except
SysThread.Terminate;
self.Terminate;
exit;
end;
SaveFStream.Size:=0;
try
SysThread.Connection.ReadStream(SaveFStream,TheFileSize);//好像经常这儿出错,不知道如何改
except
SaveFStream.Free;
SysThread.Terminate;
self.Terminate;
exit;
end;
end;
destructor TUpLoadThread.Destroy;
begin
inherited destroy;
end;
end.