Пример #1
0
        private void saveServer_Click(object sender, EventArgs e)
        {
            if (actionTitle.Text.Equals("Edit server"))
            {
                int index = serversListBox.SelectedIndex;
                if (index < 0)
                {
                    return;
                }

                sftp.setServerType(serverType.Text);
                sftp.setDomainName(domainName.Text);
                sftp.setPort(port.Value.ToString());
                sftp.setUsername(username.Text);
                stream.DeleteLines(index);
                stream.WriteLines(sftp.ToString());
                serversListBox.Items.Clear();
                ArrayList list = stream.ReadLines();
                foreach (Object obj in list)
                {
                    serversListBox.Items.Add(obj);
                }
            }
            else
            {
                sftp = new Sftp(serverType.Text, domainName.Text, port.Value.ToString(), username.Text);
                //MessageBox.Show(sftp.ToString(), "Test", MessageBoxButtons.OK, MessageBoxIcon.Error);
                stream.WriteLines(sftp.ToString());
                serversListBox.Items.Add(sftp.ToString());
            }
            ArrayList servers = stream.ReadLines();

            ftpServers.Items.Clear();
            foreach (Object obj in servers)
            {
                ftpServers.Items.Add(obj);
            }
            FtpDownload.Items.Clear();
            foreach (Object obj in servers)
            {
                FtpDownload.Items.Add(obj);
            }
            saveServer.Enabled = false;
            SetConnectionStatus(ConnectionStatus.NotTested);
        }