Advertisement
mathiasbk

FTP connect

May 21st, 2011
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.77 KB | None | 0 0
  1.         public string ftpconnect(string serveradress, string serverfolder, string username, string password)
  2.         {
  3.             try
  4.             {
  5.                 FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(serveradress + "/hei.txt");
  6.                 request.Method = WebRequestMethods.Ftp.UploadFile;
  7.  
  8.                 request.Credentials = new NetworkCredential(username, password);
  9.                 request.UsePassive = true;
  10.                 request.UseBinary = true;
  11.                 request.KeepAlive = true;
  12.                 string response = request.GetResponse().ToString();
  13.                 return "FTP Connection established!";
  14.             }
  15.             catch (Exception e)
  16.             {
  17.                 return e.Message;
  18.             }
  19.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement