Guest User

Untitled

a guest
Mar 23rd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. string _cds_stb = _cdn_stb.ToString("0000");
  2.  
  3. string ftpUser = "sasasas";
  4.  
  5. string ftpPassword = "sasasas";
  6.  
  7.  
  8.  
  9. string ftpfullpath = "ftp://www.meusite.com.br/wordpress/imagens/" + _cds_stb + "/" + _imb_prt_mnu; ;
  10.  
  11. FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpfullpath));
  12.  
  13.  
  14. //userid and password for the ftp server
  15.  
  16. ftp.Credentials = new NetworkCredential(ftpUser, ftpPassword);
  17.  
  18.  
  19. ftp.KeepAlive = true;
  20. ftp.UseBinary = true;
  21. ftp.UsePassive = true;
  22. ftp.Method = WebRequestMethods.Ftp.UploadFile;
  23. ftp.ContentLength = picture.Length;
  24.  
  25.  
  26.  
  27. Stream ftpstream = ftp.GetRequestStream();
  28.  
  29. var grava = new Task(() =>
  30. {
  31. ftpstream.Write(picture, 0, picture.Length);
  32.  
  33. });
  34. grava.Start();
  35. grava.Wait(TimeSpan.FromSeconds(10));
  36.  
  37.  
  38. ftpstream.Close();
  39.  
  40.  
  41. }
Add Comment
Please, Sign In to add comment