Esempio n. 1
0
        private void bPathOnServer_Click(object sender, EventArgs e)
        {
            FTPCredentialsConfig config = new FTPCredentialsConfig();

            config.host                  = tbHost.Text;
            config.port                  = Convert.ToInt32(tbPort.Text);
            config.usePrivateKey         = cbPrivateKey.Checked;
            config.privateKeyPath        = tbPrivateKey.Text;
            config.SshHostKeyFingerprint = sshKeyFingerprint;
            config.username              = tbUsername.Text;
            config.password              = tbPassword.Text;
            switch (cmbProtocol.SelectedIndex)
            {
            case 0:
                config.useSFTP = false;
                break;

            case 1:
                config.useSFTP = true;
                break;

            default:
                config.useSFTP = false;
                break;
            }
            //check creds

            FTPDirectory ftpdirectory = new FTPDirectory(true, config);

            if (!String.IsNullOrEmpty(tbChooseAPath.Text))
            {
                ftpdirectory.path = tbChooseAPath.Text;
            }

            DialogResult res = ftpdirectory.ShowDialog();

            if (res == DialogResult.OK)
            {
                bool isDirectory = ftpdirectory.isDirectory;
                //an den einai pare to telefteo filename
                if (!isDirectory)
                {
                    tbFilename.Text    = ftpdirectory.path.Substring(ftpdirectory.path.LastIndexOf('/') + 1);
                    tbChooseAPath.Text = ftpdirectory.path.Substring(0, ftpdirectory.path.LastIndexOf('/'));
                    if (!tbChooseAPath.Text.EndsWith("/"))
                    {
                        tbChooseAPath.Text = tbChooseAPath.Text + "/";
                    }
                }
                else
                {
                    tbChooseAPath.Text = ftpdirectory.path;
                    if (!tbChooseAPath.Text.EndsWith("/"))
                    {
                        tbChooseAPath.Text = tbChooseAPath.Text + "/";
                    }
                }
            }
        }
Esempio n. 2
0
        private void bPathOnServer_Click(object sender, EventArgs e)
        {
            FTPDirectory ftpdirectory = new FTPDirectory(true, new FTPCredentialsConfig(tbHost.Text, Convert.ToInt32(tbPort.Text),
                                                                                        cbPrivateKey.Checked, tbPrivateKey.Text, sshKeyFingerprint,
                                                                                        tbUsername.Text, tbPassword.Text, cmbProtocol.SelectedIndex == 1 ? true : false));

            if (!String.IsNullOrEmpty(tbChooseAPath.Text))
            {
                ftpdirectory.path = tbChooseAPath.Text;
            }

            DialogResult res = ftpdirectory.ShowDialog();

            if (res == DialogResult.OK && !string.IsNullOrEmpty(ftpdirectory.path))
            {
                bool isDirectory = ftpdirectory.isDirectory;
                //an den einai pare to telefteo filename
                if (!isDirectory)
                {
                    tbFilename.Text    = ftpdirectory.path.Substring(ftpdirectory.path.LastIndexOf('/') + 1);
                    tbChooseAPath.Text = ftpdirectory.path.Substring(0, ftpdirectory.path.LastIndexOf('/'));
                    if (!tbChooseAPath.Text.EndsWith("/"))
                    {
                        tbChooseAPath.Text = tbChooseAPath.Text + "/";
                    }
                }
                else
                {
                    tbChooseAPath.Text = ftpdirectory.path;
                    if (!tbChooseAPath.Text.EndsWith("/"))
                    {
                        tbChooseAPath.Text = tbChooseAPath.Text + "/";
                    }
                }
            }
        }