How do you Login to FTP using C#?
From stackoverflow
-
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); }
Ian Nelson : I tried this, had problems using it to FTP to a mainframe. Resorted to using the edtFTPnet component instead which worked like a charm. -
Something like:
var ftp = System.Net.FtpWebRequest(some url); ftp.Credentials = something;
I think... :)
-
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
0 comments:
Post a Comment