예제 #1
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            bool good = false;
            bool run = true;
            string check = chmodtxt.ToString().Remove(0, chmodtxt.ToString().Length - 3);
            //MessageBox.Show(check);
            if (which==true)
            {
                for (int i = 0; i <= 2; i++)
                {
                    if (check[i] == '0' || check[i] == '1' || check[i] == '2' || check[i] == '3' || check[i] == '4' || check[i] == '5' || check[i] == '6' || check[i] == '7')
                    {
                        good = true;
                    }
                    else
                    {
                        good = false;
                        break;
                    }
                }
                if (good == false)
                {
                    MessageBox.Show("Incorrect Format");
                    chmodtxt.Clear();
                    run = false;
                }
            }

            char owners = '7';
            char groups = '7';
            char worlds = '7';

            if (good == true && which==true)
            {
                owners = check[0];
                groups = check[1];
                worlds = check[2];
            }
            //MessageBox.Show("" + owners + groups + worlds);

            if (run == true)
            {
                try
                {
                    FtpConnection chmod = new FtpConnection(MainWindow.address.Remove(0, 6), MainWindow.c_username, MainWindow.c_password);
                    chmod.Open();
                    chmod.Login();
                    if (which == true)
                        chmod.SendCommand("SITE CHMOD " + owners + groups + worlds + " " + MainWindow.directory + item);
                    else
                        chmod.SendCommand("SITE CHMOD " + owner.ToString() + group.ToString() + world.ToString() + " " + MainWindow.directory + item);
                    //MessageBox.Show(MainWindow.address.Remove(0,6), "SITE CHMOD " + owner + group + world + " " + MainWindow.directory + item);
                    //MessageBox.Show(item + " permissions changed to " + owner + group + world);
                    chmod.Close();
                }

                catch
                {
                    MessageBox.Show("ERROR");
                }
                Close();
            }

        }