Guest User

Untitled

a guest
Feb 21st, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. FtpWebRequest ftpClient = (FtpWebRequest)FtpWebRequest.Create(FTPdestination+ i + ".txt");
  2. ftpClient.Credentials = new System.Net.NetworkCredential(user, pass);
  3. ftpClient.Method = System.Net.WebRequestMethods.Ftp.UploadFile;
  4. ftpClient.UseBinary = true;
  5. ftpClient.EnableSsl = true;
  6. ftpClient.KeepAlive = true;
  7. System.IO.FileInfo fi = new System.IO.FileInfo(server+dtm+"_"+i+".txt");
  8. ftpClient.ContentLength = fi.Length;
  9. byte[] buffer = new byte[4097];
  10. int bytes = 0;
  11. int total_bytes = (int)fi.Length;
  12. System.IO.FileStream fs = fi.OpenRead();
  13. System.IO.Stream rs = ftpClient.GetRequestStream();
  14. while (total_bytes > 0)
  15. {
  16. bytes = fs.Read(buffer, 0, buffer.Length);
  17. rs.Write(buffer, 0, bytes);
  18. total_bytes = total_bytes - bytes;
  19. }
  20. fs.Close();
  21. rs.Close();
  22. FtpWebResponse uploadResponse = (FtpWebResponse)ftpClient.GetResponse();
  23. uploadResponse.Close();
Add Comment
Please, Sign In to add comment