Ver Mensaje Individual
  #4  
Antiguo 29-05-2013
shekinax_007 shekinax_007 is offline
Registrado
NULL
 
Registrado: may 2013
Posts: 5
Reputación: 0
shekinax_007 Va por buen camino
aqui esta mi codigo

aqui esta el codigo
la variable Stramsize es una variable global de mi unit.
Código Delphi [-]
OpenDialog1.Filter := 'All Files (*.*)';  // you can add more choices by adding | and followed by description and (*.extension)
      OpenDialog1.FilterIndex := 1; // Here you follow which index number from above you want
      if OpenDialog1.Execute then
      begin
         Edit1.Text := ExtractFileName(OpenDialog1.FileName); // To send as filename after
         ClientSocket1.Socket.SendText('FILE!'+Edit1.Text);
         sleep(2000); // Need to sleep so the other end has time to process the commands
         Streamsize := TFileStream.Create(OpenDialog1.FileName, fmopenread); // Stream created just to Calculate size
         Edit2.Text := inttostr(Streamsize.Size);
         Sleep(2000);
         ClientSocket1.Socket.SendText('SIZE!'+Edit2.Text); // Sends filesize through primary socket
         Streamsize.Position := 0;
         Streamsize.Free;
         sleep(2000);
         ClientSocket2.Address := Edit3.Text;
         ClientSocket2.Open; // ready to send file on second socket
         if  ClientSocket2.Socket.SendStream(TFileStream.Create(OpenDialog1.FileName,  fmopenRead)) then memo1.Lines.Add('File Sent');
      // above creates a stream and sends as a stream its in a if line  because this is the only way it will automatically check the byte order  and send the whole stream
      end;
Responder Con Cita