加一个Button,一个NMStrm,一个NMStrmServ,一个OpenDialog
procedure TForm1.Button1Click(Sender: TObject); //发送文件
var
MyFStream: TFileStream;
begin
If OpenDialog1.Execute then
Begin
NMStrm1.Host := B机的ip地址;
NMStrm1.FromName := 这里是一些附加信息;
MyFStream := TFileStream.Create(OpenDialog1.FileName, fmOpenRead);
try
NMStrm1.PostIt(MyFStream);
finally
MyFStream.Free;
end;
end;
end;
procedure TForm1.NMStrmServ1MSG(Sender: TComponent; const sFrom: String;
strm: TStream); //NMStrmServ的OnMSG事件
var
MyFStream: TFileStream;
begin
If FileExists('./tmp') then DeleteFile('./tmp');
MyFStream := TFileStream.Create('./tmp', fmCreate);
try
MyFStream.CopyFrom(strm, strm.size);
finally
MYFStream.Free;
end;
end;