How do you Login to FTP using C#?
+2
A:
Here is a very nice FTP Client for C#
http://www.codeproject.com/KB/IP/ftplibrary.aspx
Snippett from Link
//Get the basic FtpWebRequest object with the
//common settings and security
private FtpWebRequest GetRequest(string URI)
{
//create request
FtpWebRequest result = (FtpWebRequest)FtpWebRequest.Create(URI);
//Set the login details
result.Credentials = GetCredentials();
//Do not keep alive (stateless mode)
result.KeepAlive = false;
return result;
}
/// <summary>
/// Get the credentials from username/password
/// </summary>
private System.Net.ICredentials GetCredentials()
{
return new System.Net.NetworkCredential(Username, Password);
}
bendewey
2009-02-12 15:16:26
I tried this, had problems using it to FTP to a mainframe. Resorted to using the edtFTPnet component instead which worked like a charm.
Ian Nelson
2009-02-12 15:18:24
+1
A:
Something like:
var ftp = System.Net.FtpWebRequest(some url);
ftp.Credentials = something;
I think... :)
Svish
2009-02-12 15:16:49
+3
A:
Native FTP support in .NET is fiddly.
I suggest using the free edtFTPnet component - I have used this in enterprisey applications with no problems whatsoever.
http://www.enterprisedt.com/products/edtftpnet/overview.html
Ian Nelson
2009-02-12 15:17:18