Beispiel #1
0
        private void Paths_Load(object sender, EventArgs e)
        {
            Set_Language(((fMain)this.Tag).lang());

            client = new Client();
            if (Profile.Host == null || Profile.Password == null || Profile.Username == null)
            {
                Process p = Process.GetCurrentProcess();
                p.Kill();
            }
            else
                try
                {
                    client.Connect();
                }
                catch
                {
                    Log.Write(l.Debug, "Terminating...");
                    Process p = Process.GetCurrentProcess();
                    p.Kill();
                }

            tPath.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\FTPbox";

            treeView1.Nodes.Clear();

            TreeNode first = new TreeNode();
            first.Text = "/";
            treeView1.Nodes.Add(first);

            foreach (ClientItem c in client.List("."))
            {
                if (c.Type == ClientItemType.Folder)
                {
                    TreeNode ParentNode = new TreeNode();
                    ParentNode.Text = c.Name;
                    treeView1.Nodes.Add(ParentNode);

                    TreeNode ChildNode = new TreeNode();
                    ChildNode.Text = c.Name;
                    ParentNode.Nodes.Add(ChildNode);
                }
            }

            tParent.Text = Profile.Host;
            Log.Write(l.Debug, "Host: {0}", Profile.Host);
        }
Beispiel #2
0
        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);
        }