Beispiel #1
0
        private void btnLogin_Click(object sender, System.EventArgs e)
        {
            if (ftp1.Active)
            {
                MessageBox.Show("You are already connected. Please click Logout to disconnect.");
                return;
            }

            try
            {
                ftp1.Port         = Convert.ToInt32(edtPort.Text);
                ftp1.Server       = edtServer.Text;
                ftp1.UserName     = edtUser.Text;
                ftp1.Password     = edtPassword.Text;
                ftp1.PassiveMode  = cbPassiveMode.Checked;
                ftp1.TransferType = cbAsciiMode.Checked ? FtpTransferType.Ascii : FtpTransferType.Binary;
                ftp1.Open();

                if (StringUtils.IsEmpty(edtStartDir.Text))
                {
                    edtStartDir.Text = ftp1.CurrentDir;
                }
                if (!StringUtils.IsEmpty(edtStartDir.Text) && edtStartDir.Text.StartsWith(@"/"))
                {
                    DoOpenDir(edtStartDir.Text);
                }
                UpdateStatus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void btnLogin_Click(object sender, System.EventArgs e)
        {
            if (ftp1.Active)
            {
                MessageBox.Show("You are already connected. Please click Logout to disconnect.");
                return;
            }

            try {
                ftp1.Port         = Convert.ToInt32(edtPort.Text);
                ftp1.Server       = edtServer.Text;
                ftp1.UserName     = edtUser.Text;
                ftp1.Password     = edtPassword.Text;
                ftp1.PassiveMode  = cbPassiveMode.Checked;
                ftp1.TransferType = cbAsciiMode.Checked ? FtpTransferType.Ascii : FtpTransferType.Binary;

                ftp1.ProxySettings.Server    = edtProxyServer.Text;
                ftp1.ProxySettings.Port      = Convert.ToInt32(edtProxyPort.Text);
                ftp1.ProxySettings.UserName  = edtProxyUser.Text;
                ftp1.ProxySettings.Password  = edtProxyPassword.Text;
                ftp1.ProxySettings.ProxyType = (FtpProxyType)cbProxyType.SelectedIndex;

                ftp1.Open();

                DoOpenDir(edtStartDir.Text);
                UpdateStatus();
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #3
0
        private void btnLogin_Click(object sender, System.EventArgs e)
        {
            if (ftp1.Active)
            {
                MessageBox.Show("You are already connected. Please click Logout to disconnect.");
                return;
            }

            certificateVerified = false;

            try {
                ftp1.Port         = Convert.ToInt32(edtPort.Text);
                ftp1.Server       = edtServer.Text;
                ftp1.UserName     = edtUser.Text;
                ftp1.Password     = edtPassword.Text;
                ftp1.PassiveMode  = cbPassiveMode.Checked;
                ftp1.TransferType = cbAsciiMode.Checked ? FtpTransferType.Ascii : FtpTransferType.Binary;
                ftp1.UseTls       = cbUseTLS.Checked ? ClientTlsMode.Automatic : ClientTlsMode.None;
                ftp1.Open();

                DoOpenDir(edtStartDir.Text);
                UpdateStatus();
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
        protected void Button1_Click(object sender, System.EventArgs e)
        {
            ftp1.Server   = edtServer.Text;
            ftp1.Port     = StringUtils.StrToIntDef(edtPort.Text, 21);
            ftp1.UserName = edtUser.Text;
            ftp1.Password = edtPassword.Text;

            ftp1.Open();

            string dir = edtCurrentDir.Text;

            if (!StringUtils.IsEmpty(dir))
            {
                ftp1.ChangeCurrentDir(dir);
            }

            DataTable files = new DataTable();

            files.Columns.Add("filename");

            ftp1.DirectoryListing += delegate(object sender1, DirectoryListingEventArgs args) {
                DataRow row = files.NewRow();
                files.Rows.Add(row);

                if (args.FileInfo.IsDirectory)
                {
                    row["filename"] = "/" + args.FileInfo.FileName;
                }
                else
                {
                    row["filename"] = args.FileInfo.FileName;
                }
            };

            ftp1.GetDirectoryListing();

            DataGrid1.DataSource = files;
            DataGrid1.DataBind();

            ftp1.Close();
        }
        private void btnLogin_Click(object sender, System.EventArgs e)
        {
            if (ftp1.Active)
            {
                MessageBox.Show("You are already connected. Please click Logout to disconnect.");
                return;
            }

            try {
                ftp1.Port        = Convert.ToInt32(edtPort.Text);
                ftp1.Server      = edtServer.Text;
                ftp1.UserName    = edtUser.Text;
                ftp1.Password    = edtPassword.Text;
                ftp1.PassiveMode = cbPassiveMode.Checked;
                ftp1.Open();

                DoOpenDir(edtStartDir.Text);
                UpdateStatus();
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }