示例#1
0
        private void button3_Click(object sender, EventArgs e)
        {
            Config.ConfigData config = Config.GetConfigData();
            config = Config.GetConfigData();

            // create an FTP client
            FtpClient client = new FtpClient(textBox1.Text);

            // specify the login credentials, unless you want to use the "anonymous" user account
            client.Credentials = new NetworkCredential(textBox3.Text, textBox4.Text);

            // begin connecting to the server

            try
            {
                client.Connect();
                string message = "Connection Sucessful!" + Environment.NewLine + "Click Confirm to save the settings" + Environment.NewLine + "and you can proceed with the program";
                string title   = "Information";
                MessageBox.Show(message, title,
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                button1.Enabled = true;
            }
            catch
            {
                string message = "Connection Failed!" + Environment.NewLine + "Check server information and try again" + Environment.NewLine + "Err: 02";
                string title   = "Error";
                MessageBox.Show(message, title,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                button1.Enabled = false;
            }
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            // get configuration
            Config.ConfigData config = Config.GetConfigData();


            // change data
            config.local_gate_ip = textBox1.Text;
            config.ftp_username  = textBox3.Text;
            config.ftp_pass      = textBox4.Text;
            // save config
            Config.SaveConfigData(config);
            this.Close();
            Application.Restart();
            Environment.Exit(0);
        }
示例#3
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Config.ConfigData config = Config.GetConfigData();
            config = Config.GetConfigData();
            FtpClient client = new FtpClient(config.local_gate_ip);

            client.Credentials = new NetworkCredential(config.ftp_username, config.ftp_pass);

            try
            {
                client.Connect();
            }
            catch
            {
                string message = "Connection Failed!" + Environment.NewLine + "Check server information and try again" + Environment.NewLine + "Err: 04";
                string title   = "Error";
                MessageBox.Show(message, title,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                button1.Enabled = false;
                Form2 f = new Form2();
                f.ShowDialog();
                f.Focus();
            }
            //Stream toimg = client.Download(toimg, "");
            System.IO.Stream toimg = new System.IO.MemoryStream();
            if (client.Download(toimg, "/CTI/" + listBox1.SelectedItem.ToString()))
            {
                var image = Image.FromStream(toimg);
                pictureBox1.Image = image;
            }
            else
            {
                string message = "File Not Found!" + Environment.NewLine + "Err: 03";
                string title   = "Error";
                MessageBox.Show(message, title,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            //client.DeleteFile(listBox1.SelectedItem.ToString());
        }