How to check FTP connection?
问题 Is there a simple, fast way to check that a FTP connection (includes host, port, username and password) is valid and working? I'm using C#. Thank you. 回答1: You could try using System.Net.FtpWebRequest and then just check the GetResponseStream method. So something like System.Net.FtpWebRequest myFTP = new System.Net.FtpWebRequest //Add your credentials and ports try { myFTP.GetResponseStream(); //set some flags } catch ex { //handle it when it is not working } 回答2: try something like this: