Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Internet
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 29-05-2013
shekinax_007 shekinax_007 is offline
Registrado
NULL
 
Registrado: may 2013
Posts: 5
Poder: 0
shekinax_007 Va por buen camino
Unhappy la variable TStream

disculpen x la molestia, pero necesito ayuda cn esto, stoy haciendo un proyecto acerca de sockets y conexion clients-server y necesito enviar archivos pude hacerlo como el componente opendialog de delphi que me permite seleccionar directament el archivo, pero queria saber si podria crear mi variable TfileStream directament con la direccion o directorio del archivo,el Filename y size,(lo cual puedo obtener con otras funciones) manualmente. porfaaa necesito ayuda...no es mi area la programacion por que soy de redes y telecomunicaciones pero me encantoo programar y quisiera presentar este proyecto,pues me encanto esta area.

aqui le dejo el codigo de como lo hago con el opendialog
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
  #2  
Antiguo 29-05-2013
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola shekinax_007, bienvenido a Club Delphi

Como a todos los que ingresan te invitamos a que leas nuestra guía de estilo.

Por favor, cuando incluyas código en tus mensaje usa los TAG's, se usan de este modo:



Saludos.
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita
  #3  
Antiguo 29-05-2013
shekinax_007 shekinax_007 is offline
Registrado
NULL
 
Registrado: may 2013
Posts: 5
Poder: 0
shekinax_007 Va por buen camino
ok! perdon ya mismo lo hagooo
Responder Con Cita
  #4  
Antiguo 29-05-2013
shekinax_007 shekinax_007 is offline
Registrado
NULL
 
Registrado: may 2013
Posts: 5
Poder: 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
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Liado con TStream, TmemoryStream y TFileStream madiazg Varios 1 01-12-2012 14:55:11
Duda con TStream.Readbuffer miguel_e Varios 2 04-01-2006 19:31:10
Cargar Tstream de donde? zugazua2001 Varios 1 30-07-2005 14:44:35
¿Dónde va a parar el contenido de un TStream? DarkByte Internet 10 30-01-2004 20:42:55
Modificar tStream aig OOP 14 27-06-2003 09:09:29


La franja horaria es GMT +2. Ahora son las 00:26:32.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi