private void EnviarFicheroBGWorker(object sender, DoWorkEventArgs e) { ActualizarTextboxInfoEnvio(String.Format("Enviando archivo: {0}", (String)e.Argument)); System.IO.Stream stream = System.IO.File.OpenRead((String)e.Argument); if (stream != null) { Packet packet = new Packet(); packet.stream = stream; packet.nombreArchivo = System.IO.Path.GetFileName((String)e.Argument); MetadatosInfoFichero md = new MetadatosInfoFichero(); md.LeerMetadatos((String)e.Argument); if (EnviandoFichero != null) { EnviandoFichero(this, new FicheroChangedEventArgs(packet)); } } ActualizarTextboxInfoEnvio("Archivo enviado con éxito.\n"); }
public void EnviarImagen(string rutaYNombreArchivo) { if (rutaYNombreArchivo != null && System.IO.File.Exists(rutaYNombreArchivo)) { using (FileStream fs = new FileStream(rutaYNombreArchivo, FileMode.Open)) { ImagenPacket packet = new ImagenPacket(); packet.stream = fs; packet.nombreArchivo = System.IO.Path.GetFileName(rutaYNombreArchivo); MetadatosInfoFichero md = new MetadatosInfoFichero(); md.LeerMetadatos(rutaYNombreArchivo); packet.titulo = md.Titulo; if (EnviandoImagen != null) { EnviandoImagen(this, new ImagenChangedEventArgs(packet)); } } } else { throw new ApplicationException(string.Format("Archivo no encontrado: {0}", rutaYNombreArchivo)); } }