private void bDone_Click(object sender, EventArgs e) { Log.Write(l.Debug, AppPath); bool ftporsftp; bool ftps = false; bool ftpes = true; if (cMode.SelectedIndex == 0) { ftporsftp = true; if (cEncryption.SelectedIndex != 0) { ftps = true; if (cEncryption.SelectedIndex == 1) { Log.Write(l.Debug, "FTPS Explicit"); ftpes = true; } else { Log.Write(l.Debug, "FTPS Implicit"); ftpes = false; } } } else { ftporsftp = false; } Profile.AddAccount(tHost.Text, tUsername.Text, tPass.Text, Convert.ToInt32(nPort.Value)); if (ftporsftp && ftps) { Profile.Protocol = FtpProtocol.FTPS; } else if (ftporsftp) { Profile.Protocol = FtpProtocol.FTP; } else { Profile.Protocol = FtpProtocol.SFTP; } if (!ftps) { Profile.FtpsInvokeMethod = FtpsMethod.None; } else if (ftpes) { Profile.FtpsInvokeMethod = FtpsMethod.Explicit; } else { Profile.FtpsInvokeMethod = FtpsMethod.Implicit; } try { ((fMain)this.Tag).SetTray(fMain.MessageType.Connecting); client = new Client(); client.Connect(); Log.Write(l.Debug, "Connected: {0}", client.isConnected); client.Disconnect(); Profile.AddAccount(tHost.Text, tUsername.Text, tPass.Text, Convert.ToInt32(nPort.Value)); if (ftporsftp && ftps) { Profile.Protocol = FtpProtocol.FTPS; } else if (ftporsftp) { Profile.Protocol = FtpProtocol.FTP; } else { Profile.Protocol = FtpProtocol.SFTP; } if (!ftps) { Profile.FtpsInvokeMethod = FtpsMethod.None; } else if (ftpes) { Profile.FtpsInvokeMethod = FtpsMethod.Explicit; } else { Profile.FtpsInvokeMethod = FtpsMethod.Implicit; } ((fMain)this.Tag).SetTray(fMain.MessageType.Ready); ((fMain)this.Tag).SaveProfile(); //Paths fnewdir = new Paths(); //fnewdir.Tag = this.Tag; this.Hide(); //fnewdir.ShowDialog(); //this.Close(); } catch (Exception ex) { ((fMain)this.Tag).SetTray(fMain.MessageType.Nothing); MessageBox.Show("Could not connect to FTP server. Check your account details and try again." + Environment.NewLine + " Error message: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); if (ftporsftp) { Log.Write(l.Debug, "Connected: {0}", client.isConnected); } } if (ftporsftp) { Log.Write(l.Debug, client.WorkingDirectory); } }