Ejemplo n.º 1
0
        private bool ConnectToFTP(IFtpClient client, bool message = false)
        {
            client.Host           = ipAddress.IPAddress.ToString();
            client.Port           = (int)numPort.Value;
            client.ConnectTimeout = (int)numTimeOut.Value;
            client.DataConnectionConnectTimeout = (int)numTimeOut.Value;
            client.DataConnectionReadTimeout    = (int)numTimeOut.Value;
            client.ReadTimeout = (int)numTimeOut.Value;

            try
            {
                client.GetWorkingDirectory();
                return(true);
            }
            catch (Exception ex)
            {
                if (!message)
                {
                    return(false);
                }
                MessageBox.Show("Unable to connect - please check your connection settings\n\nThe error says:\n\"" + ex.Message + "\"",
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log("Connection error: " + ex.Message);
                return(false);
            }
        }