tags:

views:

448

answers:

3
+1  Q: 

ftp login using c#

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
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
+1  A: 

Something like:

var ftp = System.Net.FtpWebRequest(some url);
ftp.Credentials = something;

I think... :)

Svish
+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