Ver Mensaje Individual
  #2 (permalink)  
Antiguo 23/03/2010, 12:27
Avatar de erick_arcini
erick_arcini
 
Fecha de Ingreso: julio-2005
Ubicación: Jaltenco / DF
Mensajes: 1.723
Antigüedad: 18 años, 9 meses
Puntos: 50
Respuesta: Ayuda envio archivo por ftp a Unix en c#

Hola maxiori te dejo esta función para cargar un archivo a un ftp

Código C:
Ver original
  1. public bool subirArchivos(string ArchivoLocal, string ArchivoGuardar, string pathFTP, string usuario, string contrasena)
  2.         {
  3.             //tagXML
  4.             //FTPFolderProductoVistaPrevia = para subir las imágenes de vista previa
  5.             bool noError = false;
  6.             try
  7.             {
  8.                 FtpWebRequest reqObj = (FtpWebRequest)WebRequest.Create(ArchivoGuardar);
  9.                 reqObj.Method = WebRequestMethods.Ftp.UploadFile;
  10.                 reqObj.Credentials = new NetworkCredential(usuario, contrasena);
  11.                 FileStream streamObj = File.OpenRead(ArchivoLocal);
  12.                 byte[] buffer = new byte[streamObj.Length];
  13.                 streamObj.Read(buffer, 0, buffer.Length);
  14.                 streamObj.Close();
  15.                 streamObj = null;
  16.                 reqObj.GetRequestStream().Write(buffer, 0, buffer.Length);
  17.                 reqObj.Abort();
  18.                 //reqObj.KeepAlive = false;
  19.                 reqObj = null;
  20.                 noError = true;
  21.             }
  22.             catch (Exception ex)
  23.             {
  24.                 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  25.                 noError = false;
  26.             }
  27.             return noError;
  28.         }
__________________
Mejoremos nuestro país, ayudemos al planeta... próximamente.