-2
 $ftp = Net::FTP -> new ( $addr, Passive => 0, Timeout => $timeout )
         or die "Failed to connect to FTP (w/ active, timeout): $addr";

what would be the C# equivalent to implement a new ftp client like the above, also what about login and controlling the transfer modes like :

 $ftp -> login ( $usr, $pwd )
   or die "Failed to login to FTP: " . $ftp->message;

  { $ftp -> ascii();  }
  { $ftp -> binary(); }
amon
  • 57,091
  • 2
  • 89
  • 149
Andres12
  • 21
  • 3
  • Your question looks similar to [this one](http://stackoverflow.com/q/1371964/1521179). Also, have you taken a look at the MSDN documentation for the corresponding [.Net classes](http://msdn.microsoft.com/en-us/library/ms229718.aspx)? (or are you using Mono instead of .Net?) – amon Jul 27 '13 at 21:39
  • http://msdn.microsoft.com/en-us/library/System.Net.FtpWebRequest.aspx – Burhan Khalid Jul 27 '13 at 21:40

1 Answers1

1

Analogous to Net::FTP in Perl would be FtpWebRequest in C# -that is, a library that speaks the protocol so you don't have to do a lot of heavy lifting yourself. Then your code is going to look like

ftpRequest = (FtpWebRequest)FtpWebRequest.Create(...);
ftpRequest.Credentials = new NetworkCredential(...);
ftpRequest.UseBinary   = true;
ftpRequest.UsePassive  = true;

(This is not real code, just typical elements you would have.) See the MSDN reference for the chapter and verse.

AlwaysLearning
  • 796
  • 3
  • 10