SHARE
TWEET

Untitled

a guest Dec 13th, 2016 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. try
  2. {
  3.     // Credenciales de prueba:
  4.     string rutaArchivo = @"C:/MiArchivo.csv";
  5.     string FTP_server = "N/A";
  6.     string FTP_username = "N/A";
  7.     string FTP_password = "N/A";
  8.  
  9.     using (StreamReader stream = new StreamReader(rutaArchivo))
  10.     {
  11.         byte[] buffer = System.Text.Encoding.Default.GetBytes(stream.ReadToEnd());
  12.  
  13.         WebRequest request = WebRequest.Create(FTP_server + nombreArch);
  14.         request.Method = WebRequestMethods.Ftp.UploadFile;
  15.         request.Credentials = new NetworkCredential(FTP_username, FTP_password);
  16.         Stream reqStream = request.GetRequestStream();
  17.         reqStream.Write(buffer, 0, buffer.Length);
  18.         reqStream.Close();
  19.     }
  20. }
  21. catch (Exception ex)
  22. {
  23.     MessageBox.Show("No se guardó el archivo: " + ex.Message);
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top