这样用NMUDP控件在局域网中进行文件的传输?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls, NMUDP;
type
TForm1 = class(TForm)
NMUDP1: TNMUDP;
Edit1: TEdit;
SpeedButton1: TSpeedButton;
OpenDialog1: TOpenDialog;
SpeedButton2: TSpeedButton;
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
myfile:tfilestream;
filename:string;
implementation
{$R *.dfm}
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
opendialog1.Filter:=*.*|*.*;
if opendialog1.Execute then
begin
filename:=opendialog1.FileName;
myfile:=tfilestream.Create(filename,fmopenread);
end;
end;
procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
NMUDP1.RemoteHost:=edit1.text;
myfile.Position := 0;
NMUDP1.SendStream(myfile);
end;
end.