Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am logging on FTP server with following code:

C#
filename = "Test.xml";
MyFtpWebRequest = (FtpWebRequest)(WebRequest.Create(ConfigurationManager.AppSettings["ftpPath"].ToString()+filename));
MyFtpWebRequest.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["User"].ToString(), ConfigurationManager.AppSettings["Password"].ToString());
MyFtpWebRequest.Method = WebRequestMethods.Ftp.UploadFile;
ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
MyFtpWebRequest.EnableSsl = true;
MyFtpWebRequest.UseBinary = true;


Which is working fine. But while logging on another FTP Server with same code i m getting error - "Unable to connect to the remote server". However the login details are correct.
It is worthwhile to mention here that another ftp details of PHP website. Let me know if here is any other method to log on PHP website or here is any error in above code

Regards!
Aman
Posted
Updated 27-Dec-10 23:16pm
v3

1 solution

Double check the connection settings (not just the login details) to make sure you are connecting to this second server properly. Particularly look at things like SSL and file paths.

Also, have a look in the other properties of the exception being thrown (assuming an exception is being thrown). It may contain additional information that gives you a hint to the problem.

The website being built with PHP shouldn't make a difference. In fact, PHP should have nothing to do with the FTP parts of the website. However, if one is a Linux server and one is a Windows server, you may find different connection settings are required.
 
Share this answer
 
Comments
Aman4.net 24-Dec-10 23:32pm    
Dear Tony Richards, Merry Christmas:) Thanx for your answer. Please explain the connection settings difference for Linux, Unix and Windows Server
Tony Richards 25-Dec-10 14:35pm    
That will depend entirely on what program the host is using for their FTP server. your best bet is to check with the host, or failing that, experiment with an FTP client like FileZilla to confirm the settings.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900