程序如下 运行时server端出现 can't not open 'd:\123.txt'
//传送端 原文件端 
unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ScktComp, StdCtrls;type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    ClientSocket1: TClientSocket;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
type csdata=record
     message_hand:array[0..20]of char;end;
var
  Form1: TForm1;
  data:csdata;
implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
var
fs:TFileStream;
    Buf:pointer;
    Size:integer;
    Send_Size:integer;
begin
 fs := TFileStream.Create('c:\123.txt' ,fmOpenRead or fmShareDenyNone);    if Fs.Size > 1024 then
        Size:=1024
    else
        Size:=fs.Size;    GetMem(Buf,Size);
    fs.Seek(0,soFromBeginning);
    fs.ReadBuffer(Buf^,Size);}
    clientsocket1.Active:=true;
    clientsocket1.socket.sendtext('123');
    ClientSocket1.Socket.SendBuf(Buf^,Size);
    Send_Size:=Size;
    fs.Destroy;
    FreeMem(Buf);}
    //Form1.ProgressBar1.Position := Form1.ProgressBar1.Position + (Size div 100);
end;
end.
服务器端
unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ScktComp;type
  TForm1 = class(TForm)
    ServerSocket1: TServerSocket;
    Edit1: TEdit;
    procedure ServerSocket1ClientRead(Sender: TObject;
      Socket: TCustomWinSocket);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.DFM}procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
  Socket: TCustomWinSocket);var
MyBuffer: array[0..10000] of byte; {设置接收缓冲区}
MyReceviceLength: integer;
S: string;
Mystream:tmemorystream;
myfile:tfilestream;
begin
myfile:= TFileStream.Create('d:\123.txt', fmOpenRead or fmShareDenyNone);
edit1.text:=socket.receivetext;
MyReceviceLength:= socket.ReceiveLength;
Socket.ReceiveBuf(MyBuffer, MyReceviceLength);
MyStream.Write(MyBuffer, MyReceviceLength);
myfile.read(myfile,MyReceviceLength);
edit1.text:=socket.receivetext;
end;
end.
如果能过让小弟正常通过 送100分